Ejemplo n.º 1
0
    private void OnUpdate()
    {
        if (Input.IsKeyPressed(KeyCode.W))
        {
            rb.AddImpulse(new Vector3(1, 0, 0));
            rb.AddTorque(new Vector3(0, 0, -5));
        }

        if (Input.IsKeyPressed(KeyCode.S))
        {
            rb.AddImpulse(new Vector3(-1, 0, 0));
            rb.AddTorque(new Vector3(0, 0, 5));
        }

        if (Input.IsKeyPressed(KeyCode.D))
        {
            rb.AddTorque(new Vector3(2, 0, 0));
            rb.AddImpulse(new Vector3(0, 0, 1));
        }

        if (Input.IsKeyPressed(KeyCode.A))
        {
            rb.AddTorque(new Vector3(-2, 0, 0));
            rb.AddImpulse(new Vector3(0, 0, -1));
        }

        if (Input.IsKeyPressed(KeyCode.Space))
        {
            rb.AddImpulse(new Vector3(0, 10, 0));
        }
    }