Object variables

Hello, I have 2 objects:

  1. NPC which has a boolean object variable “Hostile”. There are several instances of this object in the scene.
  2. A door that should be closed (let’s take just an animation switch for example) if there is at least 1 NPC that is marked as “hostile” by boolean, and open if there are none.

How can I check if there is at least 1 hostile NPC in the scene?

well checking the variable for it would work i guess, but use for each object event and the condition for checking “Hostile” boolean variable

Hi!
If you need to check the value of a variable for each instance on the scene, then you need to loop over this object: For Each events [GDevelop wiki]

I’ve tried doing this like so:

But i get this result:
Boolean

Well, I noticed my mistake, I just needed to do this like so:

1 Like