I’m refactoring my GDevelop events from separate player logic (p1, p2, p3, p4) into a single dynamic system using pVar.
Previously, the events worked when written separately for each player.
For example (Player 1 event), this one event checked Player 2 against Player 1:
check if p2 is on the same grid as p1
check if p2.team is different from p1.team
check if p1 animation is not already “attack”
if true, p1 plays the attack animation (thus attacking against p2).
I had similar events for p3 vs p1, p4 vs p1, etc., and everything worked.
To reduce repeated work, I changed it into a single dynamic event using pVar so it can handle all players.
However, after this refactor, it no longer works.
I also changed several related events and some global variables, so I’m not sure where the issue started.
Right now I can only trace the logic step by step.
My main goal first is:
how can I make the attack animation trigger again in the dynamic pVar version?
I think the problem is not the structure. When the refactored events finished for the first time, it kinda work, its just that it failed to play the attack animation.
OK. Then that’s not an issue although using a child that starts with a number even if the number is in text form is frowned against. It can be confusing and possibly create an array instead of a structure. Just verify the array in the debugger. But it shouldn’t be an issue.
Your repeat for each player, does it need all of the players or just the ones currently picked with the conditions in the first event. IDK if you need a pick all players before it.
I’m also not sure about your trigger once conditions. They don’t work well within loops and with instance since they work on an object level. Make sure they’re not causing issues.
It’s usually only necessary to control when the loop itself is triggered and not the events inside it. But it depends on your motives.