[SOLVED]Sprite shakes

P

Phemus

Guest
I wanted to make object follos object. But when I stop to moving the player and object come and stop, it starts to shaking. My code is;

move_towards_point(parent_player.x-30,parent_player.y-30,3);

Thank you.
 
C

CoderJoe

Guest
Not clear on what is shaking: the player or the object following the player? One quick idea is to put the code in the end step event.
 
P

Phemus

Guest
Not clear on what is shaking: the player or the object following the player? One quick idea is to put the code in the end step event.
The objects starting to shaking when it comes to target area.
 
C

CoderJoe

Guest
Ok. This is probably because the object moves to the target area but overshoots it a little (check the speed it is moving at). It then trys to correct itself and goes the other way creating that shaking effect. I would add some sort of check so that it only move when it is within a couple pixels of the target area. Simply get the distance between the objects and check if it is less than a certain amount.
 
D

DariusWolfe

Guest
I've had the same problem; I knew the cause, but didn't want to take the time immediately to solve the problem. I haven't implemented it yet, but riffing off of CoderJoe, it seems to me that if you do a distance check, and if it's below a certain threshold, assign x and y to the desired values, instead of using the move_toward_point() function.
 
P

Phemus

Guest
Okay. I've solved the problem with using this script:

if distance_to_object(obj_one)>10
{
move_towards_point(obj_two.x-30, obj_two.y-30,3)
}
else
{
speed = 0;
}
 
Top