Hey Aron,
I’m currently attempting to make pathfinding work on a moving plane. The goal is to have people that can freely move around on a ship. I currently have all of my actors, camera, ground and gridgraph inside a gameobject that is slowly moving. Obviously this causes problems for paths once they are calculated, as their points are static world points.
I am thinking of converting the vectorPath to local coordinates for the actor in OnPathComplete, and then iterating through those points and using transform.localPosition to move them. Would that be recommended? Is there a way I can do this so that the path gizmos remain accurate?
Hi
The recommended option is to transform it into a non-moving scenario.
Basically. Assume you have your ship with a root transform, call it root.
- Transform from world coordinates to ship coordinated (or graph coordinates if you like) by using root.InverseTransformPoint (transform.position) and similar for the target point.
- Calculate the path with those transformed points.
- Transform the path’s (vectorPath) coordinates to global coordinates again. However it is recommended to do this in the update method and not when you first get the path since the ship will probably move as the character follows the path.
This is done by something like root.TransformPoint (vectorPath[i]).
The graph should with the above configuration be positioned around the world origin. More precisely, position your ship so that root is at the world origin and not rotated or scaled, then the global coordinates should match the graph (ship) coordinates.
Regarding gizmos, sorry, that is not possible with the Seeker script. However it is relatively easy to write your own gizmo drawing code. Simply loop through all the points during update and draw transformed points using Debug.DrawLine.
Works perfectly.
That is truly amazing. Thank you so much for your help.