Display object variable of multiple instances of the same object


So i’m making a rogue-like deckbuilding game (Think Slay the Spire)
I have a card which applies ‘tar’ to an enemy. And I have a card that deals damage to an enemy for every tar that the enemy has.

For each instance of Enemy (group) Tar is applied as an object variable. In this particular scene there are two enemies, both with their own tar count. However when I try to display it as such, both the texts display the tar of only one enemy.

How can I change the Tar_Text to display the correct number of Tar each enemy has?

I believe “trigger once” is the problem. Trigger once hasn’t been known to work well with “Repeat for each instance.” If you have multiple instances with a trigger once condition, it will trigger on the first instance but that counts it as the one trigger it’s supposed to do. I think.
I might suggest you set a boolean variable for each enemy that gets set whenever the tar has been applied to prevent it from getting counted multiple times.

Something like:
object boolean variable: untarred

Repeat for each instance of Enemy:
If Enemy variable untarred = true:

  • set untarred to false
  • Create object Tar_icon at position…
  • Change the scale of Tar_icon…
  • Create object Tar_Text…
  • etc

Then another event to set variable untarred back to true prior to applying more tar.

Something like that.

Thank you, Levio, for the reply! Thanks to you I was able to solve it!

You were right in saying that ‘trigger once’ did not work well with the repeated instance. After adding your suggestion, the text was now changing independently, but sometimes it would still apply tar to the wrong target. I solved this by linking the Tar_Text to the enemy when the Tar_Text was created.

1 Like