How do I use trigger once and for each in the same event?

0 favourites
  • 4 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • In the capx below, I tried to have the game spawn the green ship, then the blue ship, based on their "Distance" from the player ship. I created a family for the enemy ships, and made a family instance variable called "DistanceX." Every second I subtract one from each ships DistanceX. The ships start out with different DistanceX's, so it will take one longer to reach zero. I wanted it to spawn each ship when it's DistanceX = zero. But they're different instances of the same object, so i used the "For each" loop, and I don't want it to spawn a million times so I used "Trigger once while true". No matter what configuration I use, it either spawns both at the same time, or spawns them in a random order endlessly. if any of you know what is wrong, or how I can acheive the desired effect, I would love it. Thank you so much, in advance.

    Link to capx: https://www.dropbox.com/s/wl6cj3urjhk96 ... .capx?dl=0

  • You dont need for each here..

    Just check the distanceX variable on the familymember and trigger once..

    Events work by filtering specific instances that meet some conditions. The actions then run for those instances only.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Here's the new capx, doing what you said: https://www.dropbox.com/s/wwzckg0gohio3 ... .capx?dl=0

    It's only spawning one, in a random order intsead of both, Green -->Blue. Is there any way I can have it spawn the green, then blue, without having to code it manually for each? Thank you, sorry for being a bother.

  • Have you used a spawn variable ? such as For every X distance Add one to spawn and run a command something like if spawn > 0 then create object and then decrease one from spawn. or you can even create something like for every X distance use variable Green ship spawn and one for Blue ship spawn.

    So that the spawn variable act as a trigger and the Spawn > 0 act a trigger for you ?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)