Page 1 of 1

X axis MoveTo ?

PostPosted: Thu Jun 18, 2015 2:56 am
by sonepoxy2015
hi,
is there a way to make an actor move to but just on the x axis?
i know there is a way with
actor.x=player.x;

but this would be to fast, i want him slowly fallow like in movto...

Re: X axis MoveTo ?

PostPosted: Thu Jun 18, 2015 8:11 am
by DeltaLeeds
So you want the actor to chase the player in a side scroller style? You can use angle, direction and directional_velocity for that. ;)
Right click the actor, go to draw actor, and paste the code below in script editor:
Code: Select all
angle=direction(x,y,player.x,y);
directional_velocity=3;//Or put different speeds to test out which speed is the best.

This code makes the actor's x move to the player's x in the speed of directional_velocity, and the y will stay constant as it will stay at y.
Hope this helps. ;)

Re: X axis MoveTo ?

PostPosted: Thu Jun 18, 2015 10:41 am
by lcl
You can use what jonathang suggests, that should do pretty much what you asked for.

Or then you can use MoveTo, but instead of making it move to the actor by selecting the actor from the list, you can make it move to it by giving the actors coordinates as the place where to move to.
Code: Select all
MoveTo("Event Actor", movetothis.x, y, 3, "Game Center", "");

Replace 'movetothis' with the name of the actor you want the event actor to move to on x axis. The value y here is the event actor's y, so it will move to the y it already is on and to the x the other actor is at.