MartinK12
Member
If player pressed "Z" then obj_player should move towards x,y of the obj_pos_z and if within 10 pixels from it, obj_player should stop.
In obj_player in step event there's only below code, but obj_player won't stop and if player presses "Z" again obj_player change direction and move towards x,y of obj_pos_z again an so on.
I know here's some basic bug but I'm tired of this code. I tried to modify it in so many ways and it's not working But it should work. There must be some logic problem but I can't see it.
Please help me bcs I don't understand where is the bug and why it don't work.
Thank You
In obj_player in step event there's only below code, but obj_player won't stop and if player presses "Z" again obj_player change direction and move towards x,y of obj_pos_z again an so on.
Code:
if keyboard_check_pressed(ord("Z"))
{
if point_distance(x, y, obj_pos_z.x,obj_pos_z.y) > 10
{
move_towards_point(obj_pos_z.x,obj_pos_z.y,walksp);
}
else
{
walksp = 0;
}
}
Please help me bcs I don't understand where is the bug and why it don't work.
Thank You