Niels
Member
Hi everyone,
I have a questions about how to implent a (easy enough for me to understand) code for for shooting enemies.
my game is in a 2d platform perspective and my player character has a machine gun that fires bullets (obviously ).
problem is that fast flying objects actually "teleport" from step to step making a collision event or place_meeting useless because the bullet will register the collision on when the enemy is at the "step-point" for the bullet.
First solution I came up was using a line for collision when shooting where the nearest enemy gets his "hp" substracted and a bloodspatter object gets drawn on that enemy.
But reading the gamemaker help files about collision_lines, I found out that collision_lines don't garantee that the instance_id that returns is the object colliding nearest to the start of the line
Then I found the following script on gmlscripts:
http://www.gmlscripts.com/script/collision_line_first
but I honestly have a hard time wrapping my head around it as GML beginner
how do I use the instance ID that returns?
Do I put in the obj_enemy step event:
"if instance_id = inst
{hp -=1
}
?
or is there a easier code to use for the hitscan line I try to make?
thx in advance
I have a questions about how to implent a (easy enough for me to understand) code for for shooting enemies.
my game is in a 2d platform perspective and my player character has a machine gun that fires bullets (obviously ).
problem is that fast flying objects actually "teleport" from step to step making a collision event or place_meeting useless because the bullet will register the collision on when the enemy is at the "step-point" for the bullet.
First solution I came up was using a line for collision when shooting where the nearest enemy gets his "hp" substracted and a bloodspatter object gets drawn on that enemy.
But reading the gamemaker help files about collision_lines, I found out that collision_lines don't garantee that the instance_id that returns is the object colliding nearest to the start of the line
Then I found the following script on gmlscripts:
http://www.gmlscripts.com/script/collision_line_first
but I honestly have a hard time wrapping my head around it as GML beginner
how do I use the instance ID that returns?
Do I put in the obj_enemy step event:
"if instance_id = inst
{hp -=1
}
?
or is there a easier code to use for the hitscan line I try to make?
thx in advance