WASD Player rotation
I'm trying to allow a player move with WASD while rotating the character model (a cube). In the update function I'm calling WASDToMove();
where agent is a NavMeshAgent
private void WASDToMove()
{
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
Vector3 targetPos = new Vector3(horizontal + rig.position.x, rig.position.y, vertical + rig.position.z);
agent.destination = targetPos;
}
This actually works great for about 15-20 seconds and then it just stops updating the destination completely while using WASD. I have another ClickToMove();
function I'm calling simultaneously (which also updates the agent's destination) and that continues to work after the WASD function stops. I've tried logging all the values; the inputs are still being updated on the key presses while the destination remains the same. Any ideas or alternative methods I should look into?
An example of the ClickToMove function I'm implementing.
Documentation on how I would expect this to work.
Your answer
Follow this Question
Related Questions
My 2d movement script isn't working 0 Answers
Why doesnt this code dash I dont see any issues with it 0 Answers
Space Invaders clone enemy movement problem 0 Answers
Limit movement to just forward/backward and left/right 0 Answers
Can you move a rigid body object forward without using relative force? If so, how? 2 Answers