[Resolved] Actions on the same line not both taking effect...seemingly.

0 favourites
  • 8 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • UPDATE

    Problem resolved - see comments below.

    ZIP FILE OF GAME .c3p

    https://drive.google.com/file/d/166Uiht-XNNaHucbyLIDLzuXLReWCF5Y5/view?usp=sharing

    WHAT I'ME TRYING TO DO

    In my Enemy Spawn System, the EnemySpawnArea objects are set to spawn an Enemy (one of three types randomly) when the animation for the EnemySpawnArea object reaches a certain frame.

    At this point, the Enemy is spawned and the value of the global variable TotalActiveEnemies increases by 1.

    NOTE: I know that I can track all the Enemies by putting them into a Family and tracking the system count value, but I would like to have a variable I can manipulate if I need to.

    WHAT'S THE PROBLEM?

    When you open the Layout 1 layout, you'll see that I have 8 EnemySpawnArea objects in the center of the arena where all the action will take place (surrounding the green square that is the Spaceship_Base object).

    When the Wave starts, color-coded "sparkles" should emit from the spawn areas that are activated (this is controlled by a separate process and everything works fine there). I have confirmed that each spawn area will only spawn one Enemy type at a time so you should be able to confirm in the system menu in debug mode that there are X Enemies as you can see visually.

    But when you check the global variable TotalActiveEnemies, it will not match the actual count of Enemies in the layout despite being calculated at the same time an Enemy is spawned - on the same action line!

    REQUEST

    Goes without saying - I need help to understand what's going on and what my oversight is so I can fix this (or if you have a quick-and-obvious-except-to-me solution!).

    I will keep working on this, myself, until I figure it out or someone provides a viable solution.

    Thank you for your time!

  • You should never use "trigger once" with objects that have multiple instances. I bet that's what causing the issue. "Trigger once" doesn't work per instance. Once the condition is true (and stays true) for one instance, it will never trigger again for other instances.

  • dop2000 - ALWAYS a pleasure to get feedback from you, Dop. :) I hope you're having a Merry pre-Christmas time!

    Thank you - after all these years of using C2/3, I don't know how I didn't realize that about Trigger Once. Eh, maybe I just forgot as I don't use it often.

    Now, curiously enough, I managed to redo my event sheet (even made it shorter by a bit) but the same problem occurred. There is no Trigger Once to worry about and I have "On Timer" behavior triggers instead... But the value for the TotalActiveEnemies global variable remains inaccurate to the number of Enemies that spawned.

  • I think if you add a for each enemyspawnarea to event 157 it should fix it.

    The on timer trigger doesn’t seem to trigger for each instance individually. Instead all the instances that finished their timer in the last tick are picked in the trigger.

    For example without the “for each” if two spawners finish their timer in the last tick and they are both “white to red” then only one would be added to the count. The for each would make it add 1 for each.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The on timer trigger doesn’t seem to trigger for each instance individually. Instead all the instances that finished their timer in the last tick are picked in the trigger.

    Yeah, I always wondered if this is intentional or a bug. Most (if not all) of other triggered events in Construct trigger for each instance.

  • Yeah, I always wondered if this is intentional or a bug. Most (if not all) of other triggered events in Construct trigger for each instance.

    I'm clearly not the expect here but I have to believe that's a bug because it doesn't make sense to have select cases where an event line that refers any instance that's True but other cases when the same set-up does not take each instance into account or it just quits once it encounters the first True instance. That gets very confusing when it's not clear when you have to apply For Each and that's been a problem I've had with Construct for years.

  • I think if you add a for each enemyspawnarea to event 157 it should fix it.

    The on timer trigger doesn’t seem to trigger for each instance individually. Instead all the instances that finished their timer in the last tick are picked in the trigger.

    Thank you, R0J0! And Merry Christmas to you and Dop, both!

    I'll give that a shot and let you know what comes of it.

  • WE HAVE A WINNER!

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