Page 1 of 1

X axis MoveTo ?

PostPosted: Mon Nov 07, 2011 6:24 am
by BogdansB
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: Mon Nov 07, 2011 6:52 am
by skydereign
actor -> Draw Actor -> Script Editor
Code: Select all
x+=5;

This will move them constantly to the right. You also have xvelocity that you can use.

Re: X axis MoveTo ?

PostPosted: Mon Nov 07, 2011 5:11 pm
by NERDnotGEEK
If you want him to follow player you use what skydereign said but put it in say an if statement.
Code: Select all
if (p.x > x+5)
{
    x+=5;
}
else if (p.x < x-5)
{
    x-=5;
}


the + and - 5 in the if statement just makes it so the thing that's following doesn't shake when its dead in line with the player

Re: X axis MoveTo ?

PostPosted: Mon Nov 07, 2011 8:35 pm
by savvy
or use the moveto command as so....
Code: Select all
MoveTo("Event Actor", 0.000000, y, 1.000000, "TARGET", "");
//moves only to the x value of the target, y is the same as the actors current y value
//meaning that the y value doesnt move!


all the above work and this one!

savvy

Re: X axis MoveTo ?

PostPosted: Mon Nov 07, 2011 9:41 pm
by skydereign
NERDnotGEEK wrote:If you want him to follow player you use what skydereign said but put it in say an if statement.
Code: Select all
if (p.x > x+5)
{
    x+=5;
}
else if (p.x < x-5)
{
    x-=5;
}


the + and - 5 in the if statement just makes it so the thing that's following doesn't shake when its dead in line with the player

For this, you can just write this line of code.
Code: Select all
x+=5*((p.x>x-5)-(p.x<x-5));

But the problem is, that BogdansB probably just wants xvelocity, since in another post was asking about PhysicalResponse. So using exclusively x won't work.

Re: X axis MoveTo ?

PostPosted: Wed Nov 09, 2011 5:55 pm
by RippeR7420
You might be able to use this code also:

Enemy->DrawActor->ScriptEditor->

Code: Select all
if(PLAYER.x<x&&PLAYER.x>x -250)
{
    x-=5;
    ChangeAnimation("Event Actor", "PLAYERRUNLEFT", NO_CHANGE);
}


if(PLAYER.x>x&&PLAYER.x<x +250)
{
    x+=5;
    ChangeAnimation("Event Actor", "PLAYERRUNRIGHT", NO_CHANGE);
}


This will make the Enemy(or whatever it is you want to move) move towards the player, but only on the X axis..