"Wandering" sprite

I was looking for a way to make a sprite wander around the map, possibly with pathfinding behaviour.

A lot of questions here. Wandering like in 8-direction (both x-axis and y-axis)?
If yes, the easiest way is to use RandomInRange(0,SceneWindowWidth()) for x axis and SceneWindowHeight() for Y axis (as a sample - change to how large your map is, for each axis) for the “Move pathfinding object to this position” action. Make this condition only call itself once the pathfinding has finished and the object has moved to the location/stopped moving (use Destination Reached condition).

However, the above might run into problems when the sprite is told to go into an object marked as pathfinding wall, I’m not sure if the condition “Destination Reached” would trigger if this is the case. If it does not you will have to make a “collision sprite” that tests if a certain point is colliding with a wall, if not it randomizes itself again before telling the sprite to pathfind to that position.

1 Like