Trigger Once Conditions Does Not Work, Why ?

0 favourites
  • 8 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • gyazo.com/befbfc33e9e849a7f6fbaa13bf048ea1

    Basically it keep spawning health every tick and the game drops to 1 fps in like 30 seconds

    Saddly can't post screenshots of code but it's like :

    For each enemy

    trigger only once = Spawn healthbar

  • your code will run approx. 60 times a second.

    you are creating 60 health bars every second for each enemy

    try "on start of layout > for each enemy" instead

  • your code will run approx. 60 times a second.

    you are creating 60 health bars every second for each enemy

    try "on start of layout > for each enemy" instead

    This only spawns health for the first enemy

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could do:

    Enemy: On created - Create health bar

    Which will run once per enemy

  • This only spawns health for the first enemy

    Well, no. Not really.

    It is 'Trigger once while true' not 'Trigger once'.

    It triggers once when the event containing that 'Trigger once while true' is true.

    When it is the only condition in that event it will trigger only that one time ... that it self runs as being true.

    And one would think that this event (containing no more conditions) cant be set to false again (actually resetting the trigger).

    That is true when it is a root event.

    But, mind the logic, this true/false has (as every variable does) a scope.

    (read about scopes --->https://www.scirra.com/manual/83/variables)

    Is it a root event, then the scope is the big tick loop.

    Bring it in a sub loop, and the scope is that loop. It will actually reset each iteration.

    I know that this make it worthless in a loop.

  • Come to think of it the easiest way is to put the health bar in a container with the enemy.

    Then it will always get created and destroyed with the enemy. (and even picked) no extra code needed

    This is a super feature of Construct 2

  • You could do:

    Enemy: On created - Create health bar

    Which will run once per enemy

    Thanks this has solved my problem

  • as i can see... you can use the container too so that on every spawn or create a monster the health bar automatically created too

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