• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM How to get 1 ef_ring per 1 bullet collision in Collision Event

F

FunkyB

Guest
Hello, I have a dumb question. There are three objects involved: the player, the enemy, and the enemy's bullet.

The idea is that the player, when a Collision Event occurs with the enemy's bullet, redirects that bullet back at the enemy. To show the user that this is occurring, I used effect_create_above( ef_ring... ).

My problem is that I only want one ef_ring to appear per bullet. Because the enemy's bullet and the player overlap, the collision event triggers repeatedly.

In an attempt to fix this, I created a variable, show_effect. Here is the code.

obj_player

Collision Event with obj_enemy_bullet

if( show_effect )
{
effect_create_above( ef_ring, other.x, other.y, 1, c_gray );
show_effect = false;
}

By setting show_effect to false, only one ring appears (which is what I want). However, many more bullets are on their way. I have just turned show_effect to false. As a result, no more ef_rings will occur (which is what I don't want).

Where can I set show_effect to true? How can I get one ef_ring per enemy bullet? Please don't shake your head too hard at me : ) Thanks for reading.
 

NightFrost

Member
Put the show_effect variable into the bullet. When player observes a collision with a bullet, it next checks its show_effect variable. If true, the effect is displayed and variable is set to false; if false, skip.
 
F

FunkyB

Guest
Put the show_effect variable into the bullet. When player observes a collision with a bullet, it next checks its show_effect variable. If true, the effect is displayed and variable is set to false; if false, skip.
Hey NightFrost, thank you for the reply. I just took your advice and gave the variable "show_effect" to the bullet rather than the player. It works perfectly.

Thanks again for your help!
FunkyB
 
Top