I am checking Vector3.dot for current tanks position and what is the next little step the tank is trying to go step. Based on that inn trying to put the Acceleration input or turning input to whatever the dot returns. But the problem is, it’s turning too fast and accelerates too fast to point its just wiggling and driving in circles trying to reach said point. How can I make a system which works based on a* pathfinding?
Green circle is forward/reverse, blue circle is turning. Let’s assume pink is target. How do I get the tank to pass right thru the pink cube?
With the values written on screenshot the tank will wiggle side to side, or even drift around at full throttle around the target point unable to get it.
I was thinking of adding a deadzones of 0.1 to the blue circle, so if it’s only 9 degrees, it doesn’t turn, I though of doing it the same thing to the speed, but if the points are straight in a row this will be a problem. If the tank has to brake even tho it’s driving straight.
You need to make it slow down as it approaches the target point. Also you should probably disable turning if the target is closer than say the (approximate) radius of the tank, since turning will look really bad in that case.
But a* uses multiple agent points. If it slows down for each point while driving in generally straight line it will look even worse. And yeah, noted about the radius on trello todo.
A* gets the path once and then keeps it, which means if the tank has moved elsewhere from the path, the path isn’t being updated. The tank is told to move like 5 units ahead, but it ends up drifting in circles because it never crosses that point it was told to cross.
Is there a reason you are not using one of the built-in movement scripts? They handle all of this automatically.
They may not be the best for realistic vehicle movement, but they will get you going much faster.
The default script it came with seemed good, but then the tank acted differently from player.
It turned, it drove, but it looked as if it’s sliding to the target point.
If I can use the same logic that the script uses, maybe my issue would be solved. But I need it to work on inputs. Go forward (-1 to 1) or turn (-1 to 1) same as input axis work. I couldn’t read the default scripts either.