B
Blaize
Guest
Ok, so right now, I'm using collision_line() in a Megaman.exe-style game as part of a sensor-like function.
So, let's have a look at this image:
Ok, so the one with the green square is the player and everything else is an enemy. The white rectangle is our player's collision line. It's origin is from the left or right bbox, depending on which way it's facing (ie. Right uses bbox_right, left uses bbox_left).
Now, when facing right (as in the image), collision_line will return 100007, as expected.
However:
In this situation, collision_line will still return 100007 instead of the one closer to the player.
I've been wrestling with this for a while, but still can't get my head around it.
Here's my code:
I have a feeling that it is picking up both, but returning the instance with the lower ID? Could be wrong
Much appreciated.
So, let's have a look at this image:
Ok, so the one with the green square is the player and everything else is an enemy. The white rectangle is our player's collision line. It's origin is from the left or right bbox, depending on which way it's facing (ie. Right uses bbox_right, left uses bbox_left).
Now, when facing right (as in the image), collision_line will return 100007, as expected.
However:
In this situation, collision_line will still return 100007 instead of the one closer to the player.
I've been wrestling with this for a while, but still can't get my head around it.
Here's my code:
Code:
#macro COMBATGRID 64 (This is in a Macros script)
if (_attack && AttackTimer == 0)
{
var _xOrigin = x+(Facing==1?bbox_right:bbox_left); //Facing == 1 means right; -1 means left. 0 is disregarded
var _hit = collision_line(_xOrigin,y+(COMBATGRID/2), (Facing==1? room_width : 0),y+(COMBATGRID/2),pCombatActor,false,true);
with (_hit)
show_debug_message("Hit "+string(id));
}
Much appreciated.
Attachments
-
27.8 KB Views: 23
-
27.8 KB Views: 24