Exemplo n.º 1
0
    HouseMesh CreateHouseMesh(HouseMesh.MeshType type)
    {
        GameObject gameObject = new GameObject(name + "-" + type);
        HouseMesh  houseMesh  = gameObject.AddComponent <HouseMesh>();

        houseMesh.transform.parent = transform;
        houseMesh.island           = island;
        houseMesh.type             = type;
        houseMesh.Init();
        return(houseMesh);
    }
Exemplo n.º 2
0
    public void Init()
    {
        RecalculatePosition();
        roofMesh = CreateHouseMesh(HouseMesh.MeshType.Roof);
        baseMesh = CreateHouseMesh(HouseMesh.MeshType.Base);
        Rigidbody rigidbody = gameObject.AddComponent <Rigidbody>();

        rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ;
        BoxCollider collider = gameObject.AddComponent <BoxCollider>();

        collider.size   = new Vector3(0.2f, 0.3f, 0.2f) * 1f;
        collider.center = new Vector3(0, -0.3f, 0);
    }