- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
alexander_khan · Dec 04, 2021 at 03:49 PM ·
cameracharactercamera rotatecharacter movementrotate-move
Camera rotation movements player
So I'm tried to achieved third person camera. I used cinemachine and settings the camera to "Follow" the players. then the camera rotation I script with based on Horizontal Mouse
transform.Rotate(0, Input.GetAxis("Mouse X"), 0);
but the problem is the character only move forwards, not direct toward to the camera move. the script for movement is below
public float currentMaxSpeed = 1.0f;
void Update()
{
movement(); //w,a,s,d move
}
void movement()
{
transform.Rotate(0, Input.GetAxis("Mouse X"), 0);
Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0.001f, Input.GetAxis("Vertical"));
transform.position = transform.position + movement * Time.deltaTime * currentMaxSpeed;
}
that's all for that, sorry for my bad English I hope it helps.
Comment
Your answer
Follow this Question
Related Questions
Camera stucks at the spawn position 1 Answer
How to rotate my camera? 2 Answers
Limit camera RotateAround for an UAV game 0 Answers
How do I keep the player from automatically changing direction? 2 Answers