Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        proj         = GetComponentInChildren <Projector> ();
        renderer     = GetComponentInChildren <SkinnedMeshRenderer> ();
        plantType    = PlantType.potato;
        initialRot   = headBone.localRotation;
        leftLookRot  = initialRot * Quaternion.AngleAxis(turnAngle, Vector3.right);
        rightLookRot = initialRot * Quaternion.AngleAxis(-turnAngle, Vector3.right);
        rotOffset    = Random.Range(0f, Mathf.PI);

        // turn us to face the nearest path
        WorldTile[] neighbours = PlantManager.GetNeighbouringCells(gridPos);
        for (int i = 0; i < neighbours.Length; i++)
        {
            if (neighbours [i].tileType == TileType.path)
            {
                transform.LookAt(new Vector3(neighbours [i].x, 0, neighbours [i].y), Vector3.up);
                break;
            }
        }
    }