Пример #1
0
    void FixedUpdate()
    {
        // have you been out of contact with the ground a long time?
        if (contactTracker.GetTimeSinceContact() >= ContactLingerInterval)
        {
            return;
        }

        // turn first
        float Rdrive = input.GetHorizontal();

        if (Mathf.Abs(Rdrive) > 0.1f)
        {
            rb.AddTorque(transform.up * Rdrive * Twist);
        }
        else
        {
            // damp out rotation
            rb.AddTorque(-rb.angularVelocity * Twist);
        }

        // then drive
        Vector3 Zdrive = transform.forward * input.GetVertical() * Power;

        rb.AddForce(Zdrive);
    }
Пример #2
0
    void FixedUpdate()
    {
        Vector3 XZdrive = new Vector3(input.GetHorizontal(), 0, input.GetVertical());

        XZdrive *= Power;

        XZdrive = transform.rotation * XZdrive;

        gameObject.GetComponent <Rigidbody>().AddForce(XZdrive);
    }