The problem is that the randomly generated values are identical for each instance, which I do not want. I want the enemies to attack at different places.
This question is related (Creating multiple instances of an object with random values in them) but it wasn’t able to help me because the enemies in my game are not created after the scene begins and generating random variables multiple times does not result in different variables for each instance on my side.
Does anyone know how to approach this problem? Thanks! I apologize I couldn’t add more images, I’m new and can only embed one image at a time :D.
Your event will run once and set the same random values for all the picked enemies. You need a “for each object” event to repeat the same actions for each enemy instance separately.
I don’t know what the object’s center point is set to but for random in range the 2nd number needs to be larger than the first because it’s used as a range. Example 1 to 100 works while 100 to 1 won’t. I believe it would always return 100.
It’s currently using +150 and -150. Repending on the value of centerX and cwnterY, switching the order of the values might fix it.
I’d suggest a slightly more efficient method. Put those two conditions in a normal event, and then move the “Repeat for each stationary_enemy_1”` as a sub-event off that.
This way the repeat only goes over the eligible objects, and not over all objects to see if they’re eligible. There is a processing cost with the latter.
removing the “trigger once” event spawns multiple copies of the attack, which I need only one of since the game is turn-based (sorry for not providing enough info!).
In that case, ditch the repeat event, and use a standard event with a “Pick random stationary_enemy_1” condition. There’s no point in have a repeat if you only want the events to be actioned once.