Beispiel #1
0
    public void UpdateMove()
    {
        if (canMove)
        {
            switch (direction)
            {
            case CAR_DIRECTION.FRONT:
                gameObject.transform.position += transform.forward * speedMove * Time.deltaTime;
                break;

            case CAR_DIRECTION.LEFT:
                if (rotation <= (angleStart - 90))
                {
                    direction = CAR_DIRECTION.FRONT;
                }
                rotation          -= speedRotation * Time.deltaTime;
                transform.rotation = Quaternion.Euler(new Vector3(transform.eulerAngles.x, rotation, transform.eulerAngles.z));
                // move
                transform.position += transform.forward * Time.deltaTime * speedMove;
                break;

            case CAR_DIRECTION.RIGHT:
                if (rotation >= (angleStart + 90))
                {
                    direction = CAR_DIRECTION.FRONT;
                }
                rotation          += speedRotation * Time.deltaTime;
                transform.rotation = Quaternion.Euler(new Vector3(transform.eulerAngles.x, rotation, transform.eulerAngles.z));
                // move
                transform.position += transform.forward * Time.deltaTime * speedMove;
                break;
            }
        }
    }
Beispiel #2
0
 void ChangeStateMove()
 {
     direction = GetRandomEnum <CAR_DIRECTION>();
     canMove   = true;
 }