Dear all
I want to freeze the rotation of an rigid body object in y and z axis.
and also i want the object must be an rigid body.
Can any one please help me in this matter.
Thanks in Advance
Dear all
I want to freeze the rotation of an rigid body object in y and z axis.
and also i want the object must be an rigid body.
Can any one please help me in this matter.
Thanks in Advance
Hello ![]()
Well… if you want to freeze the rotations (all axis) there is a checkbox on the rigidbody attribute that does that for you…
but if you want only to freeze the rotation on y and z…
what I would do is on the Update just keep assigning a same rotation to the Y and Z axis…
hope it helps ![]()
Dear sir.
Thank you very much for your reply.
Can you please send some sample code for that function sir.
Thanking you
raja
Dear sir.
I have made the object to be freeze in specific axis namely y,z;
and also i Freeze the movement of the object in x,y axis.
i freeze the object in FixedUpdate function sir.
But the object is shaking. Do you have any solution for reduce the shaking of the object sir.
Thanking you
Raja ![]()
Code:
function FixedUpdate ()
{
if(Input.GetButton(“Fire1”))
{
Addpower(50.0);
}
if (a >=5.0)
{
//steeringInput = Input.GetAxis(“Horizontal”) ;
motorInput = Input.GetAxis(“Vertical”) ;
}
a =a + 0.1;
if(Input.GetButton(“Jump”))
{
motorInput = 0.0;
}
rigidbody.rotation.y = 0.0;
rigidbody.rotation.z = 0.0;
rigidbody.position.x = 424.2006;
rigidbody.position.y = 32.44331;
Setting the rotation of a rigidbody object will often cause problems if it is in contact with another object. You can, however, heavily reduce rotation about two axes while still allowing a bit of slack to avoid the shaking. You can use rigidbody.AddForceAtPosition to apply two opposing pulling forces at either side of the centre of mass. This is a bit like having a piece of string running through the centre of the object - if you pull the string tight, it can rotate around the string, but won’t rotate in any other axis.
Dear sir.
Thank you for your reply sir.
Can you please send me a sample code which explains this function.
It will be a great help for me sir.
Thank you in Advance
Raja