I am a beginner I stated unity about 9 months now I made several 3d games I am making a 2d game and I am trying to freeze all positions of my players in an if statement how to do that in a 2d game
Assuming you have a Rigidbody2D (in a variable called myRigidbody), you can use:
myRigidbody.constraints = RigidbodyConstraints2D.FreezeAll;
And if you just want to freeze your position and not your rotation, you can use:
myRigidbody.constraints = RigidbodyConstraints2D.FreezePosition;
Hope this helped:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.