- Home /
Is scripting "Rigidbody2D.freezeRotation = true;" inside void Update() the best way to freeze rotation in a 2d game?
My character rotates when it walks against obstacles. I thought I could fix this in the Rigidbody2D part of the inspector, but the "Info" dropdown is greyed out. I edited the playermovement script to freeze the rotation inside void Update(), and this workaround works, but I'm worried it might cause poor performance. Am I just being paranoid?
Answer by I_Am_Err00r · Aug 28, 2019 at 08:38 PM
Everything in Update() will drain on performance, but for a 2D game you're probably not going to run into frame rate issues by doing what you're doing, but there is a better way and you can delete that line from your code.
See in this photo of a Rigidbody2D the constraints tab? In there you can stop the z rotation, which is probably the only axis giving you trouble right now.
...I forgot you could click on the Constraints button. Thank you very much!