TheMPC
1
Hello again,
My next question will probably be easy to answer but i failed to find the answer myself:
Im trying to freeze my Rigidbody's rotation, but only for the Y rotation and not for the X, is there any way i can preform this?
Greetings,
TheMPC
qJake
2
It's really easy, actually:
// C#
public class FreezeRotation : MonoBehaviour
{
public float lockedRotation = 0;
void Update()
{
transform.eulerAngles = new Vector3(transform.eulerAngles.x, lockedRotation, transform.eulerAngles.z);
}
}
That component will allow you to lock your Y-rotation on any euler angle you specify. Make sure that "lockedRotation" is [0...360].
duck
3
You can also do this without any script.
Just add a Configurable Joint component, and set the "Angular XMotion" and "Angular ZMotion" to "Locked".