Hi guys I am maybe missing something trivial here but I can’t just get my agent to move directly from gamepad input. He either moves with significant unpredictable lag aiPath.Move or doesn’t move at all tried with Move + FinalizeMovement or using RVOController. Is there an example moving agents with Gamepad? This seems like something that should be easy, I mean I am switching from Navmesh where simple NavmeshAgent.Move does the trick without any other stuff to implement to make it work.
What kind of lag?
Does the game reduce in FPS? Is the agent’s movement not smooth? Is there a delay between your gamepad input and the agent’s movement?
Kind of hard to describe, it is not gamepad delay, for example if I keep changing the delta value in Move each frame it will not move at all, it just starts moving if the delta is the same for atleast 2 frames.
Anyway will play with it a bit longer if I can find a better description of the behaviour.
For the movement there is nothing special just a Grid graph and AIPath on the agent. With Move call in the Update method when joystick magnitude is bigger than 0. Nothing really to post.
_aiPath.Move(p_delta); // Where p_delta is normalized joystick input vector*constantAgentSpeed.
Yep it is actually. in the speed. But even if it wasn’t it should either not move at all or move at all times so didn’t really found that significant as that would just affect the amount of movement.
Ok got it, it is kind of a quirky problem so if anyone has the same one here is the explanation.
Firstly what I forgot to mention is that I use RigidBody on the agent, I didn’t think this was relevant but it sure is as I delved to the A* code and if you use Rigid on the object it is using rigid.position instead of transform.position. Nothing wrong with that, however internally Unity applies this rigid transformation to the actual gameobject at fixed time steps and after that it uses it to update rendering obviously. For some reason if you change the rigid position in nonlinear way (notusing same direction of change) this never happens, if anyone has an answer to this I would like to know.
Solution however is pretty easy once you know what is happening, you either move the call to FixedUpdate or enable rigidbody interpolation.