It seems this issue comes up a lot for me, and I cant seem to remember how to fix it.
Imagine a standard platformer, with a player just moving around. Then we have a simple enemy that walks around, until he encounters the player.
When that enemy encounters the player, its supposed to shoot fire at the player. The fire object is just a normal object that has a bouncing ball movement, speed 60 and decel 60, when its animation is finished it's destroyed. All of this works fine.
The event structure is something like this:
*all the junk for enemy is close to player*
-Create *fire* at (0,0) from enemy
-set direction of fire to Direction(Enemy) + random(2) - 1
So that should create the fire object, and shoot it off in the direction its facing, along with the direction above and below it. (right?)
Well it seems to work perfectly when theres only one of these enemies in the frame. If I have two enemies in the frame, each one on the opposite side of the player, the "set direction" event seems to choose the wrong Enemy when gettings it's direction.
Note: In the second shot the player is invisible because hes flashing with temporary invincibility. Also in that second shot, there was a third enemy walking around to the left of the window, I dont know if that had any effect on it.
Well I'm stuck. I'm not really good at fast loops and all that jazz. I tried making it do something along the lines of "If fire is overlapping enemy, and fire flag 0 is off, then set fire direction to direction of enemy, set fire flag 0 on" but that still screws up.
Hmm... are the enemies themselves actually facing left and right as it appears?
If so, the easiest way would be to set the direction as you're creating it.
That is, when you're choosing where the object is created, you can press "options" (assuming this hasn't changed in MMF2) and set the object being created to inheret the directional orientation of the object it's being created relative to.
Then you can add that random direction jitter afterwards if you want.
It doesn't matter if you're creating enemies on the fly because MMF will keep track of them for you. When you spread value into them they each get assigned a number based on the order in which they were created. Just do your fastloop for the number of enemies you currently have and then run the firing events inside the loop.