- Home /
Rigidbody.MoveRotation() Towards an object?
In short: I want an object to follow rotation of another object, but with slight delay (a lag), like it was heavy - How can I do it so that it also detects collision? I know it will be something like Rigidbody.Moverotation( but I have no idea where to get it from there.
EDIT: Scenario: I want an automatic turret to always slowly follow where a First-Person Camera of the palyer is looking. For example, you look to the right - turret is also turning to the right to match camera's rotation.
Help?
Answer by ShadyProductions · Mar 02, 2020 at 01:11 PM
This question was already asked several times:
https://answers.unity.com/questions/417920/how-to-make-a-rigidbody-rotate-towards-an-object-u.html
Yes, but that's not the question I needed answered. These all links show how to "turn a rigidbody to look at another object". What I need is for Rigidbody to follow the rotation of another object with a slight lag.
Scenario: I want an automatic turret to always slowly follow where a First-Person Camera of the palyer is looking. So you look to the right - turret is also turning to the right to match camera's rotation.
Just apply the player's forward vector to the rotation of the turret?
There are two problems: A) Assigning rotation is simple, but I don't want the tutrret to sharply turn - it's supposed to feel heavy, so it needs to rotate more slowly towards the current camera rotation. B) I want to preserve Collisions, so when the turret hits something on it's way to the proper rotation, I want it to push against the obstacle or to stop completely if the obstacle is static.
Considering both of these things, I found out I should use Rigidbody.$$anonymous$$oveRotation() (it applies new rotation but considering phyiscs collisions. But I can't just make it Turret.rigidbody.$$anonymous$$oveRotation(Camera.rotation), because it will just snap the turret instantly to the final position.
I would need sometihng like Turret.Rigidbody.$$anonymous$$oveRotation(stepTowardsCameraRotation), but I have no idea how to say that in Quaternions :/
Your answer
Follow this Question
Related Questions
How may I observe expected physical interactions while using Rigidbody.MoveRotation()? 1 Answer
Camera and mesh not colliding 1 Answer
What is the most accurate method of calculating total rotations of a rigidbody? 1 Answer
drag object including free rotation 0 Answers
How do i keep a rigidbody upright? Looking for best way to freeze rotation 1 Answer