SnowBoard Game Problem (Editor vs Build)

Everything tuned nicely in the Unity Editor but when I built and ran it, the snowboarder character rotated very slowly in the built version. (I’m guessing that the problem had something to do with the FPS difference and I’m sure I could have set a target frame rate in a script. But, I’m just picturing that solution working fine until it is run on another computer that can’t achieve the target FPS set in code.)

So, I asked AI for a little assistance and then added the code below (to PlayerController.cs). RotatePlayer() was removed from Update() and everything else is pretty much the same as in the lesson. The code below seemed to have corrected the problem.

[SerializeField] float torqueAmount = 80f;
[SerializeField] float maxAngularVelocity = 200f;

void FixedUpdate() {

    // Clamp the angular velocity to the maximum value
    rb2d.angularVelocity = Mathf.Clamp(rb2d.angularVelocity, -maxAngularVelocity, maxAngularVelocity);

    RotatePlayer();
}

Privacy & Terms