How do I trigger an event on every instance of an object, one after the other ?

0 favourites
  • 5 posts
From the Asset Store
Game Triggers is as versatile as a Swiss army knife, and will be a great resource for any type of game you're creating.
  • Hi everyone !

    I'm currently making a snake-like a game, and I want to add a "swallowing" effect.

    For that, I want to trigger a "Set enable Sine behavior"(Sine behavior has Size movement) on each instance of my snake body (which is composed of several segments, each segment is an instance of the same object).

    With that, when my snake eat a bonus, each segment of his body from head to tail would increase then decrease in size, one after the other.

    I tried to use a For each (ordered) condition + On collisiong between the head of my snake and a bonus, but it didn't work at all.

    I hope someone could help me with that !

  • "On collision" picks only 1 instance of the object (the one that collided). You need to pick all instances, do this:

    Snake On collision with bonus
    ...(subevent)..System Pick All Snake 
    .......(subevent)..Snake set width to [something]
    

    .

    Another option is to use a function -

    On collision call function "IncreaseSnakeSize"

  • I tried this but it didn't work :/ It seems conditions aren't met.

    By the way, the head of the snake isn't the same object as the segments in my code.

    Maybe using families can help, I'm trying something.

  • You'll want to use a Timer behavior in conjunction with the for each ordered, and use the loopindex as the time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It seems that using the Time behavior with a For each (ordered) works, thanks ! But the outcome is not yet satisfaying.

    The more the snake eat bonus the less the sine movements of each segment are synchronized.

    Still working on it !

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