Hey all,
I have got pathfinding kind of working with a touch to move to position function. I was just wondering how I can make a vehicle move on a road and follow a road layout with the path finding function and only certain vehicles go onto grass and Forrest once they have reached the touched location on the road so they don’t cut across the map?
Thankyou in advance
If you add obstacles that blocks off areas then before the action to move the player, you can enable or disable the object’s obstacle behavior. The pathfinder only uses enabled obstacles to plot a path. Once the object is moving, the state of the obstacle doesn’t matter.
You could pick the obstacles based on any condition like an object variable or layer. You could have other objects that are always obstacles.
The built-in pathfinder uses the bounding box. It might be easier to use the nav mesh pathfinder behavior. It uses the collision box. It has a matching obstacle behavior.
This test project uses an ID object variable and objects named Player1, Player2, wall, Door and a couple of text objects. Theres also a group that contains the players.
Try me. Click a player to make them active. The green one can go anywhere.
Note:This uses the Nav Mesh behavior. The method would almost be identical for the default pathfinder except for the draw mesh action. There is an extension for drawing the path for the defeat pathfinder. The obstacle would also need to be rearranged. If this was the default pathfinder the entire bounding box around the black object wouldn’t be reachable.
https://gd.games/keith_13579/missions
You can use the built-in pathfinder. I prefer it. You might need to use more obstacles since it uses the entire object not the collision box. So, to do irregular shaped borders, you would need to break the obstacles into smaller pieces or squares.
There are probably other methods.
1 Like