Question by
lucasisrael813 · Nov 19, 2021 at 06:41 PM ·
rotationmovementraycastmovement scriptplane
How to limit the rotation speed of my player
Hey, i found a guide on google on how to rotate the player in the direction of the mouse and it works perfectly fine. But Iam trying to tweak things a little by limiting the speed my player can rotate to make it a bit more realistic. This is my Code im using right now void Update() {
Plane plane = new Plane(Vector3.up, 0);
float distance;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (plane.Raycast(ray, out distance))
{
worldPosition = ray.GetPoint(distance);
Debug.Log(worldPosition);
transform.LookAt(new Vector3(worldPosition.x, transform.position.y, worldPosition.z));
}
got any suggestion for me? Thanks alot.
Comment
Your answer
Follow this Question
Related Questions
Character Rotation 0 Answers
Fixed Update randomly stops player rotation 0 Answers
How do I rotate my object back to the world's up direction whilst keeping it's forward direction? 0 Answers
Click to Rotate towards raycast, then Move 1 Answer
How can I incorporate a Rotation Towards the Mouse Position into this Script? I Tried. 0 Answers