I have implemented a system in my first person game, that if i am close to an enemy it makes me automatically aim at it.
And the problem is, that i don’t know how to align the movemet, now if the player comes into that radius he is still moving into that direction, the camera was looking before.
But i want that if i am in that locked camera mode, that when i walk forward i am walking into the direction of the enemy, and side ways i want to walk around the enemy in a circle. but i dont know how to implement it.
My current movement code:
if (distance >= lookRadius)
{
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * speed * Time.deltaTime);
}
else
{
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * speed * Time.deltaTime);
}