How does Construct handle similar events in the same tick?

This forum is currently in read-only mode.
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Hi all

    I'm trying to understand how Construct works, and I have a quick question about how Construct handles similar events that occur within the same tick.

    Let's say I have two families, Red and Green, and 10 objects in each family.

    I have an event set up like this:

    -On collision between Red and Green

    Action: Set global variable(speedxRED) to Red[physics]VelocityX

    Action: Set global variable(speedyRED) to Red[physics]VelocityY

    Action: Set global variable(speedxGREEN) to Green[physics]VelocityX

    Action: Set global variable(speedyGREEN) to Green[physics]VelocityY

    I then use other events to do further calculations with those global variables and apply some actions to the objects that collided.

    My question is, if the situation occurs that two independent collisions happen within the same tick, will Construct treat each collision separately, and first store the values in the global variables for one of the collisions, then overwrite them with the values from the other collision? Or will it just be a big mess?

    Also, if they are treated separately, will Construct go trough the entire chain of events involving the global variables for one of the collisions, and then do the same with the other collision? Or is there a risk that the other collision will mess up any ongoing calculations that is happening with the first collision?

  • The events will take place in order. All the calculations for the collision event for all instances will take place before the next condition is evaluated. There shouldn't be a "big mess". I believe that given your scenario, the assignment to the global variable would occur only once using the value of the first picked instance. Don't quote me on that until you test it, which should be simple enough. The first picked instance in the selected object list is not simple to plan for, especially in families with multiple types, so if you need greater control over which object pv gets used add further conditions or subevents. If you would like for each private variable to be used in succession, use a "for each" condition or a "for each ordered" condition which would also allow you to specify the order the objects were acted upon. Also, just to clarify, construct never runs anything concurrently, everything is evaluated and executed top to bottom, except with special cases like "start of layout", loops, and functions

  • Also, just to clarify, construct never runs anything concurrently, everything is evaluated and executed top to bottom, except with special cases like "start of layout", loops, and functions

    And just to add to the "start of layout" thing:

    Multiple start of layout events will still run in the order of the event sheet. The ones higher on the list will run before the lower start of layout events. Basically anything that has a green arrow next to it is a trigger, which means that it runs when called, but the order still matters when there is multiple identical triggers.

    I know you're probably asking about using globals in this situation as a hypothetical situation to learn more about construct, but in case you didn't think of it, private variables would be better in this case. Each collided pair of instances would have their values set accordingly, and you can use subevents to modify the values without losing the picking.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • All the calculations for the collision event for all instances will take place before the next condition is evaluated.

    That's handy information

    Thanks guys, I understand it a bit better now

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