This is a weird one. I'm using a 2d adaptation of the NavMesh (found here: https://github.com/h8man/NavMeshPlus) to get obstacle avoidance for my AI in my 2d game.
I also want to use it for my player controller, so that I can get collisions with walls for 'free' without having to use a box or circle collider and deal with any clipping issues. So currently my player component has a Rigidbody2d set to Kinematic, a circle collider (to register collisions with bullets etc.), and a Nav Mesh Agent component. In the Start method of my script, I was told to add these lines:
agent.updateRotation = false;
agent.updateUpAxis = false;
I used to use this method of moving the player in the
FixedUpdate loop (which also has vertical-movement jittery issues when paired with the Nav Mesh Agent):
transform.Translate(new Vector3(moveVal.x, moveVal.y, 0) * moveSpeed * Time.fixedDeltaTime, Space.World);
However I read that I'd want to set the agent's velocity to make it better suited to being avoided by enemy AI, if required. So I tried...
agent.velocity = new Vector3(moveVal.x, moveVal.y, 0) * moveSpeed;
Ok, this works... but it only works in the x direction. If I hit W or S on keyboard to move vertically, it does nothing. However, if I hold both vertical AND horizontal move keys down, it works! ...bizarre.
I did try this with joystick movement and it also worked fine, which is also bizarre. I logged out
moveVal.y for both control methods; the keyboard values were always either 1, 0, or -1, whereas the gamepad/joystick values were floats anywhere between -1 and 1. (I'm using new input system with an action type of Value and control type Vector2)
And yes, I did try commenting out the
agent.updateUpAxis = false line since it did look suspicious to me too, but that didn't change anything unfortunately.