Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        // If not paused
        if (Time.timeScale == 1)
        {
            if (Input.GetKey(this.moveUp))
            {
                vehicle.Accelerate();
            }
            else if (Input.GetKey(this.moveDown))
            {
                vehicle.AccelerateBack();
            }

            if (Input.GetKey(this.moveLeft))
            {
                vehicle.TurnLeft();
            }
            else if (Input.GetKey(this.moveRight))
            {
                vehicle.TurnRight();
            }
            else
            {
                vehicle.SetWheelAngle(0);
            }

            vehicle.Action();

            int k = 60;

            rigidBody2D.velocity = new Vector3((float)(Math.Sin(vehicle.Direction) * vehicle.Speed) * k, (float)(Math.Cos(vehicle.Direction) * vehicle.Speed) * k);

            //transform.position = vehicle.Origin;
            transform.eulerAngles = new Vector3(0, 0, (float)(180 - Mathf.Rad2Deg * vehicle.Direction));
        }
    }