O
O_Steven_007
Guest
Hello Im looking for help on a player to object issue. I am currently testing the player to enemy collision and each time I run the game the enemy Character collision box does not register and instead ignores collisions and runs right on top of the player. I do not know what the problem is as I am following a tutorial word for word.
Here is the enemy Step event that I am using for tracking the player and registering collisions.
Here is the enemy Step event that I am using for tracking the player and registering collisions.
Code:
/// @description Insert description here
TargetX = obj_player.x-x;
TargetY = obj_player.y-y;
var _targetX = sign(TargetX);
var _targetY = sign(TargetY);
if (place_meeting(x + _targetX, y, obj_collision))
{
while (!place_meeting(x+sign(_targetX), y, obj_collision))
{
x += sign(_targetX);
}
_targetX = 0;
}
x+=_targetX;
if (place_meeting(x, y + _targetY, obj_collision))
{
while (!place_meeting(x, y +sign(_targetY), obj_collision))
{
y += sign(_targetY);
}
_targetY = 0;
}
y+=_targetY;