- Home /
How to rotate rigidbody relative to jointed other rigidbody?
The target is quite simple, I think, but I don't see easy solution. I have a physicaly moving rigidbody (let's think this is a tank) and another rigidbody, attached to first one (call it turret) with Hinge Joint. Player has control booth of them. Tank can move forward and bacward and turn around, turret can only turn around.
Problem 1: When we rotate only tank, the turret is not turning with it, it just keep orientation.
Problem 2: When we rotate booth tank and turret, the turret rotation speed is not related on tank rotation speed and direction.
If my code is needed, I can post, but it is too big.
Answer by Aldeminor · May 04, 2014 at 01:10 AM
Why do you need a hinge joint? Why isn't the turret simply a child object of the tank?
Unfortunately, child hierarchy affects rigidbodies uncorrectly, requires tons of additional scripts and affects perfomance.
Hinge joints have all kinds of parameters to limit their movement which greatly complicates the thing.
If it is, so I'm a little misunderstand something. Hinge Joints' Spring function can set the "zero" position and force turret rotate to it when player release "turret turn" key, but that is not what I want. I did not found how Hinge Joint can translate tank's Y angle to the turret.
Answer by Jeff-Kesselman · May 03, 2014 at 10:57 PM
Why do you need a hinge joint? Why isn't the turret simply a child object of the tank?
Hinge joints have all kinds of parameters to limit their movement which greatly complicates the thing.