OblivionSkull21
Member
I am making a bullet hell-style combat system. I just incorporated a mechanic where the player can "near-dodge" projectiles. What I mean by this is if the projectile just barely misses the player. I calculated this using collision_circle:
The above code checks to see if there is a collision of the bullet with a collision_circle around the player object. It also checks to make sure the projectile hasn't hit the player (isn't at 0 distance) and it checks to make sure the player isn't in "recovery state" from having been hit by a bullet previously.
If a collision is found, it sets that specific bullet to the inst variable and enables near_miss, which gives the player +1 mp for near-dodging.
This works almost completely, if the player actually manages to dodge the bullet. HOWEVER, there's an issue involved where the moment the bullet crosses that collision_circle, it's registering as a dodge even if the bullet still ends up hitting the player. For example, I dodge a bullet, and it gives me +1 mp, but the bullet still ends up hitting me, so I don't want to get that mp.
I guess the best way I could think to go about this is to save the bullet's id the moment it crosses over the collision circle and ONLY add mp if the bullet manages to exit the circle (doesn't hit the player). How would I go about that code wise? Are there any other methods you could think of?
GML:
if collision_circle(x - 1,y - 1,13,obj_bulletparent,true,true) && distance_to_object(obj_bulletparent) != 0 && !recover{
if inst == noone || (instance_nearest(x,y,obj_bulletparent) != inst){
near_miss = true;
inst = collision_circle(x - 1,y - 1,13,obj_bulletparent,true,true)
}
}
If a collision is found, it sets that specific bullet to the inst variable and enables near_miss, which gives the player +1 mp for near-dodging.
This works almost completely, if the player actually manages to dodge the bullet. HOWEVER, there's an issue involved where the moment the bullet crosses that collision_circle, it's registering as a dodge even if the bullet still ends up hitting the player. For example, I dodge a bullet, and it gives me +1 mp, but the bullet still ends up hitting me, so I don't want to get that mp.
I guess the best way I could think to go about this is to save the bullet's id the moment it crosses over the collision circle and ONLY add mp if the bullet manages to exit the circle (doesn't hit the player). How would I go about that code wise? Are there any other methods you could think of?
Last edited: