- Home /
How to rotate a rigidbody without its attached anchor rigid body flying off?
Hi I'm new to rigid body physics and interactions.
I have rigidbody object that I want to rotate (like a turret) on another rigidbody object. I am trying to use the hinge joint as that seems appropriate. But when I run the game the whole thing disappears (probably thrown off into infinity). It needs to be rigidbodies as the "turret" will actually be a swivelling jet and apply force to the whole thing.
This is the script that I am trying to attach:
rot = Mathf.MoveTowardsAngle
(transform.localEulerAngles.y, angleAdjusted, speedd * Time.deltaTime);
// transform.localEulerAngles = Vector3(0, rot, 0); [this doesn't work either]
rigidbody.rotation.y = rot;
I've tried it both with parented and non parented objects and still the same problem. It's like they are trying to repel each other but can't because they are stuck together. So they fly off.
We need more info to help you.
Do they have colliders? If they have colliders are the colliders intersecting each other? Are they just falling due to gravity? What happen to there transform after you started your game?
yes they have colliders. I don't think they intersect as i am using primatives. They fall due to gravity when I start the game, but rest on the ground and remain in configuration. When I activate the script it all goes mad.
Your answer
Follow this Question
Related Questions
Hinge Joint? Unconstrained. 1 Answer
Rigidbodies misbehaving when another is rotated 0 Answers
Hinge Joints, distance to connected body 1 Answer
add force to rotation 1 Answer