- Home /
La domanda ha avuto risposta, è stata accettata la risposta giusta
Player Rotation Movement
Hi everyone I have a script that allows me to move my character in the direction of input and facing the camera even if it is rotated. I'll post the rotation script. Except that I would need to rotate the character by an expected angle as well as it travels the horizontal axis, so it should walk in circles. I can't look at a logical result does anyone know how to help me, Thanks
if (movementDirection != Vector3.zero)
{
float targetRotation = Mathf.Atan2(horizontalInput, verticalInput) * Mathf.Rad2Deg + Camera.main.transform.eulerAngles.y;
transform.eulerAngles = Vector3.up * Mathf.SmoothDampAngle(transform.eulerAngles.y, targetRotation, ref rotateSmoothVelocity, rotateSmoothTime);
}
Answer by Venividiviciuus · Apr 16 at 10:24 AM
For anyone interested I have happily solved this problem by adding a simple simple input to the camera. By rotating the camera, the character also assumes the desired rotation.
To Camera Script
void WalkAroundInput()
{
currentX += Input.GetAxisRaw("Horizontal") * speed * Time.deltaTime;
}
Follow this Question
Related Questions
Rotate an object to a given point 2 Answers
object rotation 1 Answer
How Do I rotate a Object Based On the player's location? 1 Answer
A way to store multiple rotation modes 1 Answer
How to turn the steering wheel 0 Answers