Hello,
I am using the A* Pathfinding Project with Unity for an RTS game.
Currently, I am using AIPath for unit movement. The pathfinding, acceleration, deceleration, and avoidance features work very well, so I would like to keep using AIPath instead of replacing the whole movement system.
However, I have a problem with vehicle-like units (for example tanks).
The default AIPath movement seems to work like this:
-
The agent calculates a desired velocity vector.
-
The transform position is moved directly according to this velocity vector.
-
Rotation is handled separately.
Because of this, the unit can move sideways while its forward direction is different from the movement direction.
Example:
Tank forward direction:
↑
Actual movement:
↗
The result looks like the tank is sliding/drifting.
For a tank or vehicle, I would like the movement model to be:
-
AIPath calculates the path and provides the next steering target.
-
The unit rotates towards the target direction.
-
Acceleration/deceleration controls a scalar speed value.
-
The final movement direction is always
transform.forward.
Something like:
desired direction = AIPath steering target
rotation = rotate towards desired direction
speed = accelerate/decelerate
velocity = transform.forward * speed
Is there a recommended way to achieve this while keeping AIPath’s:
-
path calculation
-
acceleration
-
slowdown distance
-
local avoidance (RVO if possible)
?
Should I:
-
Override some AIPath methods such as
MovementUpdateInternal()? -
Implement a custom
IAstarAImovement controller? -
Use AIPath only for path following and write my own movement update?
-
Is there already a built-in option for vehicle-style movement?
I would like to avoid disabling AIPath completely because its acceleration and stopping behaviour are very useful.
Thank you!