How to check at least one of an object is true?


I’m trying to crate a lift. and I have done it. but I want to add sounds for that. so I added isActivteLift Boolean variable to the scene.

I want to know, How to get only one object for condition? there are many “lift” objects. I want to play lift sound, If at least one of any lift object is active.

Simply in here, I want to check at least one of any “lift” object is true. (any condition for that?)

EDIT: Here is my project files, SFAC-GDevelop.zip - Google Drive
(Press UP,DOWN arrows to control lifts , collide with controllers)

  • You’ve to check every lift object and then decide if you’re playing a sound or not. So, create a boolean type scene variable to hold the result, for example “playSound”.
  • Use a For Each Object loop to check all the lift objects.
  • Set playSound to false before the loop.
  • If the For Each Object finds an active lift, set playSound to true.
  • After the loop is finished, play the sound if playSound is true.
1 Like

If Erdo answer is not what you are looking for can you explain

  • are you lifting like a box and you want sound of the moment when picking it up?
  • or sound when walking with lifted object?

Or is it something else?

  • you have levers that are lifted and you want to play sound only when one of them is lifted? Like alarm? and if next one is lifted you don’t want 2 alarm sounds to be played?

Also

  • does sound should play all the time or you want it to play only when lifting object happens?
1 Like

I have added project files, please check

I have added project files, please check

1 Like

@ZeroX4 Thank you so much! That worked.