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
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
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].
You can also do this without any script.
Just add a Configurable Joint component, and set the "Angular XMotion" and "Angular ZMotion" to "Locked".
While configurable joints are a scriptless solution, I've found some instances where they don't work... which is why I suggest the script solution instead. :P
– qJake
I did not, I must admit I'm new to the website and didn't know how replies/comments worked. Thanks a lot @wideeyenow_unity !! I'm reading it right now, I would be more than happy to join your discord server if you still doing that. I'll let you know how it goes, thanks again!
– alvarofrodrigueza1