示例#1
0
 void OnTriggerExit(Collider other)
 {
     if (pipeInContact != null)
     {
         pipeInContact.state = state = AxisPipeState.rotatingAndMoving;
     }
     pipeInContact = null;
 }
示例#2
0
 void OnTriggerEnter(Collider other)
 {
     pipeInContact = other.gameObject.GetComponent <AxisPipe>();
     if (pipeInContact != null)
     {
         pipeInContact.state = state = AxisPipeState.rotating;
     }
 }
示例#3
0
        // Update is called once per frame
        void FixedUpdate()
        {
            if (Mathf.Abs(distanceTravelled) > distanceToTravelBeforeDespawn)
            {
                Destroy(gameObject);
            }
            if (stopped)
            {
                return;
            }

            switch (state)
            {
            case AxisPipeState.rotatingAndMoving:
                Rotate();
                Move();
                break;

            case AxisPipeState.moving:
                Move();
                break;

            case AxisPipeState.rotating:
                Rotate();
                if (pipeInContact != null)
                {
                    float angleBetween      = Quaternion.Angle(pipeInContact.transform.rotation, transform.rotation);
                    float closeEnoughCutoff = 2;
                    if ((angleBetween + closeEnoughCutoff) % 60 < closeEnoughCutoff)
                    {
                        pipeInContact.state = state = AxisPipeState.moving;
                    }
                }
                break;
            }
        }
示例#4
0
 // Use this for initialization
 void Start()
 {
     state = AxisPipeState.rotatingAndMoving;
 }