Hi all! How can I make each of the newly created sprites follow the moving hitboxes? I’ve been trying to think of a way and I saw the FOR EACH OBJECT: REPEAT function but I’m no programmer and it’s making my nose bleed for a few hours now trying to figure out how to make it work. I’m trying to make enemies appear in patterns similar to Shoot Em Up group enemies, you get the idea.
Purple boxes are just hitboxes that move from right to left and the yellow diamond is supposed to be the enemy but somehow it just follows the last hitbox spawned from the right.
I don’t know how to use the function properly as well.
The problem is the event 5, it iterates over each EnemyBox, but moves every Enemy to it, because there is no condition to choose a specific Enemy.
I’ve fixed it, in two ways:
WIth an ID variable, after creating an EnemyBox and an Enemy, “link” them with the same (unique) ID variable, then, iterate over each EnemyBox as you do but move the Enemy with the same ID.
With the extension to link objects, after creating the objects, link them, then move the Enemy linked to the current EnemyBox in the For each loop.
Both versions are here: My project 4.zip (13 KB)
To make the things clear, I’ve merged the two events that looks pretty similar (3 and 4).
De/activate each version to confirm both of them work
WOW! I’m just blown away with how easily you solved the problem with just two simple methods, with I could do that. Thanks a whole bunch for answering my questions, appreciate it a lot!
@Lizard-13
Now I can relax with the options you gave me. I tried looking for tutorials about Variable IDs on the Wiki and Google but couldn’t find one, only the Child Variables have topics. And the AND/OR statements look so much cleaner and more professional now that you fixed them! One last thing though, I tried using the Path Behavior on the Enemy sprite and changed the Path Position (X,Y) to the EnemyBox position but it didn’t give the desired result of enemies moving up and down (Sine movement) but rather it gave some interesting results. Is there a Sine behavior or function I’m not aware of?
@MattLB
Nice! It’s a cool and trippy action and would be very useful for my insect or zombie enemies. Thanks a lot!
It may not be useful for your game, but I’ve just noticed that if you set the damping on the force applied to enemybox to a non-zero value (e.g. 0.05) it turns the spawn object into rather a good missile launcher.