- Home /
Constrain Rigidbody Y Axis Rotation in World Space
I want to clamp the Y rotation of a rigidbodys physics in World Space to then be able to set it in code. This would leave the physics on x and z.
Thanks Dan
Answer by phxvyper · May 20, 2016 at 10:47 PM
If you want to have the ability to manipulate it in code, then do something like this:
public float RbodyAxisY = 0f;
void FixedUpdate() {
Vector3 newRot = Rbody.rotation.eulerAngles;
newRot.y = rbody_y_axis;
Rbody.rotation = Quaternion.EulerAngles(newRot);
}
and change the value of RbodyAxisY whenever you want in your script.
This works for the most part, but when the rigidbody goes upside down it starts to "flip out" and dances around on its end. Any ideas how to prevent this?
Answer by RichardBDev · Aug 26, 2020 at 08:36 PM
I know this is a four year old thread, but I'm looking to do the exact same thing and I was wondering if there was a fix for the object flipping out?
Your answer
Follow this Question
Related Questions
How to make an object(cylinder) always at the center of an object(Terrain)? 0 Answers
How not to make a RigidBody not go into ground when tilted foward? 1 Answer
how to shot a soccer ball in curve path according to the swipe type 2 Answers
Balancing in a bike game 0 Answers
Orbit cam and Rigidbodies aiming 0 Answers