For Each trigger only triggering once even though there are multiple objects

0 favourites
  • 4 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hi, I'm not sure why this is happening but I've been playing with the debug mode and whenever the "Adventurer" object triggers for overlapping it will properly spawn the "dummyAttack" object for each occurrence, however the for each trigger for "dummyAttack" does not properly subtract damage from the hp instance variable of the "Enemy" object. I've checked with debugging there is indeed multiple instances of the "dummyAttack" and the target UID's on them are also properly mapped but the trigger subtracts HP from 1 Enemy at a time.

    https://puu.sh/FdVaX/7b704c6f20.png[/img]

    I've been racking my brain over this and can't figure it out so if someone has some insight on this it would be greatly appreciated.

  • If these are top-level events, then "For each DummyAttack" is triggered on every tick, but you have another condition "Every DummyAttack.attackSpeed seconds".. Not only this is not good for performance, but I can't imagine how these two conditions work together, especially if different instances have different attackSpeed values.

    Use Timer behavior instead. When DummyAttack is spawned, start its Timer. In "On timer" event do "For each DummyAttack", pick Enemy, subtract from health.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If these are top-level events, then "For each DummyAttack" is triggered on every tick, but you have another condition "Every DummyAttack.attackSpeed seconds".. Not only this is not good for performance, but I can't imagine how these two conditions work together, especially if different instances have different attackSpeed values.

    Use Timer behavior instead. When DummyAttack is spawned, start its Timer. In "On timer" event do "For each DummyAttack", pick Enemy, subtract from health.

  • If these are top-level events, then "For each DummyAttack" is triggered on every tick, but you have another condition "Every DummyAttack.attackSpeed seconds".. Not only this is not good for performance, but I can't imagine how these two conditions work together, especially if different instances have different attackSpeed values.

    Use Timer behavior instead. When DummyAttack is spawned, start its Timer. In "On timer" event do "For each DummyAttack", pick Enemy, subtract from health.

    Thank you very much, this was exactly it.

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