I am currently trying to use A*Star along with Kinematic Character Controller so far I’ve found two ways to implement movement however both are a bit janky at the moment.
While having AIDestination component running to update the path constantly, I pull the “steeringTarget” variable from the IAstarAI component. In practice, I then use the steering target as a way to determine where the controller should be moving with below code:
_moveInputVector = (agent.steeringTarget- transform.position); _moveInputVector = Vector3.ClampMagnitude(_moveInputVector,1f); _lookInputVector = _moveInputVector ;
- It starts to bug out if the y position is greater than the controller’s. I.e if a player is on a platform above. I solved this by setting the Y to always use the controllers Y pos.
*I dont know how much processing power this actually uses but its less than manually recalculating based on how many points are left.
Store vectorPath list then have the controller walk towards all of them, remove them at a certain distance. Once the list is empty, recalculate and start the process over.
If the player moves, it won’t account for that. I also noticed that alot more zigzagging in the pathfinding.
Instead running through the whole vectorPath list, I only use the index variable vectorPath to move to, once it’s reached I clear the list and recalculate the pathfinding and repeat. I found this method the best so far as it only calculates once the 1st path is reached.
All three methods still have zigzagging issues which I don’t know how to fix it, there isn’t any zigzagging when using the test scenes only in my own. Here is a screencap of the test map im using.