[Solved]Pathfinding and obstacles

The cow only moves once after “x” time and then stands still even though the timer resets.

And how can I check if the destination point is in collision with say “a wall”? Otherwise, the cow won’t reach its destination and the timer won’t reset.
Ty

I don’t know why you do it as a sub-event. Do it as a separate event. In the main event there is the condition that the variable DestinationReached is 1 but the following action changes it to value 0, therefore when you want to execute the sub-event it will not do so due to the condition of the event to which it belongs is that the DestinationReached value is 1.

Okay I understand but my problem is that it does that even with it being a separate event and/or without the variables “DestinationReached”

You should activate the timer before using it as a condition (for example, when starting the scene). On the other hand, the values ​​of the DestinationReached variable are used incorrectly both as a condition and in action. Here I send you an example that works perfectly.

To confirm, you’ve moved the subevent to be on the same level as the first cow event?

Because I’ve tried myself, and it works fine:

As a subevent, it won’t. as a subevent, the check that the cow reaches it’s destination will only occur once, and that’s when the move to position is applied. After that, is won’t check it again because the object variable DestinationReached will always remain 0.

Moving it to a normal event means checking the cow has reached it’s destination is checked every frame.

No need to instantiate the time at startup - GDevelop is neat in that it creates the timers and variables if they don’t already exist.

To avoid the cow colliding with a wall, add an “Obstacle for Pathfinding” to any objects that the cow cannot pass through.

But if you do that, you’ll also need to do a check that “A path was found for Cow” after the “Move Cow to …” action, to avoid moving the cow to an unreachable position.

This is a change that you could use to not just depend on whether the path was found, and it worked for me. You will have to adjust it according to the needs of your game.

Okay cool thanks.

Why must the post be 20 characters long😩

This topic has been solved🔒