[Solved] Object Following the Player

D

DinoRoar

Guest
Hi everyone. I am trying to get one object to follow the player object after the player object collide with the other object. I can get the other object to move after the player object collide with it. However, it seems to continue follow the old direction of the player unless the player touches it again and it will then continue going in that old direction unless it collide with the player again. (I am guessing I need to make sure the script updates the position of the player character but I am unsure how.)

I used the Drag and Drop collision with the player together with this code.

if point_distance(x, y, obj_player.x, obj_player.y) > 15
{
move_towards_point(obj_player.x, obj_player.y, .9);
}
else speed = 0;

Many thanks for any help!
 

Shawn Basnett

Discount Dev
Set that code in the step event and use a variable to check the collision, it will update the player movement.

Something like this


CREATE FOR OBJECT
Code:
collided = false;
COLLISION WITH PLAYER
Code:
collided = true;
STEP FOR OBJECT
Code:
if point_distance(x, y, obj_player.x, obj_player.y) > 15 && (collided = true)
{
move_towards_point(obj_player.x, obj_player.y, .9);
}
else speed = 0;
 
Top