"Distance between 2 objects" condition not working when inverted

so, I have some events where when you get close enough (below 64 pixels) to an npc, you’re able to talk to them. (shown by a Z bubble)
but for some reason, the “talkable” variable for the npc won’t go back to 0 after you’re far away enough, even though it’s supposed to.

Here are those events.

Here’s the issue played out.

When I start the event:
image

When I’m close enough (talkable variable is 1):
image

Where it goes wrong (the talkable variable is supposed to go back to 0):
image

Do you have more than 1 NPC in the scene? Because the way you got it coded, and the way GDevelop works, that would explain the problem you’re getting.

Also keep in mind that “For each” and “Trigger Once” don’t play together as you’d expect.

Trigger once is “once for this entire event”, not that instance. So using trigger once in a for each means it will only apply to the very first instance.

2 Likes

I do have more than one npc in the scene. what should I do? it seems to work just fine when there’s only one…

You’ll have to change the way you deal with them.

Here’s a link to the problem explained in more detail, and a work around. Have a look at this, and see if you can make it work for your game.

Not sure if this works but I’ve found these kind of variable changes work best when you have them set to 0 under no condition, and changed to 1 only when under a certain distance. That way it will revert automatically when the 1 condition is not met. I.e., you won’t need a specific revert to 0 condition.

1 Like