- Home /
Keeping relative rotation to another object
I have a scenario where player can pick up a box and look around while holding it. I want the box to behave the same way as if it had become a child of player object, but I want to achieve this using physics.
It is essential that the picked up object keeps its rotations while player is rotating. i.e. always face the player the same way it was when it got picked.
Here is a demonstration picture:
I tried this:
Quaternion relative = Quaternion.Inverse(originalRotation) * player.rotation;
box.transform.rotation = player.rotation * relative;
that almost does it, except there is weird small offset everytime object is picked.
How I move the object:
box.transform.GetRigidBody().velocity = 10f * (player.position -box.transform.position);
Your answer
Follow this Question
Related Questions
why can't my Rigidbody not rotate on slopes? 1 Answer
Limit Rotation of Rigidbody to 45 Degrees (Handlebars on a Bicycle) 1 Answer
Barrel rotation Y, not working well with rigidbody. 2 Answers
Rotate Rigidbody to always face a force 0 Answers
Why can't I assign a rotation to a rigidbody Object? 1 Answer