Physics still wonky. Very slow. What is wrong?

ezgif.com-optimize

As you can see, if I allow my ship to fall such that it catches the edge of a platform, you would expect it to start spinning and quickly fall to the floor, unless I apply thrust, however it behaves very unrealistically. Any ideas? I haven’t watched ahead to see if this is addressed, but the video seems to indicate we now have bugless flights.

Try to play with physic material properties on rigidbody. Maybe add bounciness, standard material is sticky.

Last night I figured it out in my sleep!

The problem with how it’s coded in the lesson is that the rotation method which is being called every frame is constantly freezing and unfreezing the rotation regardless of the user input:

Note: “rb” is the name of my Rigidbody

private void ApplyRotation()
    {
        rb.freezeRotation = true;

        if (Input.GetKey(KeyCode.A))
        {
            transform.Rotate(Vector3.forward, RotateSpeed * Time.deltaTime);
        }
        if (Input.GetKey(KeyCode.D))
        {
            transform.Rotate(-Vector3.forward, RotateSpeed * Time.deltaTime);
        }

        rb.freezeRotation = false;
    }

So I moved the freeze/unfreeze into the If statements…

private void ApplyRotation()
    {
        if (Input.GetKey(KeyCode.A))
        {
            rb.freezeRotation = true;
            transform.Rotate(Vector3.forward, RotateSpeed * Time.deltaTime);
            rb.freezeRotation = false;
        }
        if (Input.GetKey(KeyCode.D))
        {
            rb.freezeRotation = true;
            transform.Rotate(-Vector3.forward, RotateSpeed * Time.deltaTime);
            rb.freezeRotation = false;
        }
    }

That fixes the physics problem, however a discovered another bug that arrises by unfreezing rotation… it unfreezes the rotation X & Y axis that we manually froze earlier, so after you rotate once, you can now get messed up.

Remove all freezes, instead play with rigidbody angular drag value. This what i did some time ago. Angular drag is a value that slows rotation over time.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms