- Home /
How to limit sprite rotation
Hey all,
I am trying to limit a sprite's rotation to just the x and y axis'
I locked down the z axis rotation and z axis movement of it's rigidbody in the inspector. However when two instantiated sprites collide with each other, they end up rotating in the z direction. How do I fix this?
I have tried attaching a configurable joint to help lock down the rotation but it was of no use.
Any help would be appreciated! Thanks!
I think this is a pretty awful way to do it, and the proper way to do it I believe would be to use mathf.clamp, but I'm pretty new to scripting so unfortunately I can't provide an awesome script. But as a temporary gross solution you could do:
transform.rotation.z = 0;
in Update()
You can't modify this directly in C#, you'll need to declare it as a new vector first.
Your answer
Follow this Question
Related Questions
Link object rotation to its parent 1 Answer
How to lock down the rotation when keys are pressed? 1 Answer
How to rotate object in instantiate with float value 1 Answer
Clamp rotation of a GameObject 1 Answer
How to set an exact Local angle. 0 Answers