GML [Solved]Problem: Same Type Objects not all being affected by script/instance_exist check

K

Ken Joust

Guest
So the issue is that when I create an object called obj_slow_time, it is supposed to slow all enemies down to 20% then reset them back to their original speed when the obj_slow_time destroys itself. However, when obj_slow_time is created in the room, it only slows down a single (first enemy of an object type created in the room.) The script is in the parent object of both enemy types, I've already tried putting the scripts in the different enemy type objects separately with no change </3.
I am at a hugeeeeee loss.

This is the script that is on the End Step of the parent object for my enemies.
time slow script.png
Then this is the code for the object that is created and destroyed after a certain amount of time. (It destroys itself and works, and actually slows down a SINGLE enemy correctly.)

This is the Create Event for obj_slow_time
create event.png


And this is the step event of obj_slow_time


step event.png

I've noticed that only the first created type of an enemy is affected by this code. So if I had 5 wolves and 3 tigers coming at you, the obj_slow_time will only slow the first wolf and the first tiger created in the room.

I am quite new to GameMaker and to the coding world, so forgive my ignorances.
Any help would be much appreciated as this is quite frustrating!
I can post other code if need be.
Thanks for reading.
 
P

PandaPenguin

Guest
that's because you have the check for instance_exists() in you parent object and you "reset" your timeSlowed in the first check too

this way only one child object can be processed as you have a timeSlowed = false for all next coming child objects
 
Last edited by a moderator:
K

Ken Joust

Guest
that's because you have the check for instance_exists() in you parent object and you "reset" your timeSlowed in the first check too

this way only one child object can be processed as you have a timeSlowed = false for all next coming child objects
Thanks for the quick reply!
I understand the issue, especially for the timeSlowed = false for the next objects. Makes complete sense! I'll try adjusting the instance_exists() and the timeSlowed.
Thanks again so much, it was frustrating not knowing what the issue was haha
EDIT: Fixed it by moving the timeSlowed = false statement to the step event in the obj_time_slow. Now all children of the enemy parent are affected. It's very satisfying, thanks again.
 
Last edited by a moderator:
Top