X axis MoveTo ?

Game Editor comments and discussion.

X axis MoveTo ?

Postby BogdansB » Mon Nov 07, 2011 6:24 am

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...
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: X axis MoveTo ?

Postby skydereign » Mon Nov 07, 2011 6:52 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: X axis MoveTo ?

Postby NERDnotGEEK » Mon Nov 07, 2011 5:11 pm

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
NERDnotGEEK
 
Posts: 75
Joined: Sat Oct 30, 2010 1:48 am
Score: 12 Give a positive score

Re: X axis MoveTo ?

Postby savvy » Mon Nov 07, 2011 8:35 pm

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
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: X axis MoveTo ?

Postby skydereign » Mon Nov 07, 2011 9:41 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: X axis MoveTo ?

Postby RippeR7420 » Wed Nov 09, 2011 5:55 pm

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..
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob: (On the back burner)

-StickMcGee - Blast to the Future http://game-editor.com/forum/viewtopic.php?f=4&t=13660
User avatar
RippeR7420
 
Posts: 391
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 23 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest