Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 17,416 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
path scripting #127547
05/01/07 15:31
05/01/07 15:31
Joined: Mar 2007
Posts: 69
L
luke_was_ere Offline OP
Junior Member
luke_was_ere  Offline OP
Junior Member
L

Joined: Mar 2007
Posts: 69
I have a model of a car, i want it to move about a predefined route over and over. Now i have read about using Paths to be the way forward. This is what i have done:

clicked Add path and then used vertex move to draw out the area to follow, then i assigned the model of my car to the path in the properties path menu.


Now i am told i need a script to get it to follow it. any ideas on how to do this?

After looking in the manual i found this but not sure if its relevant:

// move along a path loop
// uses _FORCE, _MOVEMODE
action patrol_path
{
// attach entity to nearest path
result = path_scan(me,my.x,my.pan,vector(360,180,1000);
if (result == 0) { return; } // no path found

// find first waypoint
var node = 1; // start at first node
path_nodepos(my,node,my._TARGET_X);

while (my._MOVEMODE)
{
// find direction
result = vec_to_angle(angle,vec_diff(temp,my._TARGET_X,my.x));

// near target? Find next waypoint of the path
if (result < 25) {
node = path_nextnode(my,node,1);
path_nodepos(my,node,my._TARGET_X);
}

// turn and walk towards target
actor_turnto(angle.PAN);
actor_moveahead(MY._FORCE);
wait(1);
}
}



I have never really done any scripting in this before so please bear with me :-)


cheers

Re: path scripting [Re: luke_was_ere] #127548
05/02/07 15:22
05/02/07 15:22
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
sorry i couldn't help you via email, paths are hard for me as well...


- aka Manslayer101
Re: path scripting [Re: mpdeveloper_B] #127549
05/02/07 23:04
05/02/07 23:04
Joined: Mar 2007
Posts: 69
L
luke_was_ere Offline OP
Junior Member
luke_was_ere  Offline OP
Junior Member
L

Joined: Mar 2007
Posts: 69
thanks any way buddy :-)

Re: path scripting [Re: luke_was_ere] #127550
05/03/07 18:22
05/03/07 18:22
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Try this:
Code:

//skill1: TurnSpeed 10
//skill2: MoveSpeed 10
action patrol_path()
{
// attach entity to nearest path
result = path_scan(me,my.x,my.pan,vector(360,180,1000);
if (result == 0) { return; } // no path found

var NodePos[3];

// find first waypoint
var node = 1; // start at first node
path_getnode(my,node,NodePos,NULL);

var angle[3];

var Gravity;

while (1)
{
// find direction
result = vec_to_angle(angle,vec_diff(temp,NodePos,my.x));

// near target? Find next waypoint of the path
if (result < 25)
{
node = path_nextnode(my,node,1);
path_getnode(my,node,NodePos,NULL);
}

my.skill21 = c_trace(my.x,vector(0,0,-10000),use_box|ignore_me|ignore_passents|ignore_passable);
if(my.skill21 > 5)
{
Gravity -= time_step;
}else
{
if(my.skill21 < 0)
{
Gravity += time_step;
}else
{
Gravity = 0;
}
}

// turn and walk towards target
my.pan += ((angle.pan > my.pan)-(angle.pan < my.pan))*time_step*my.TurnSpeed;
c_move(me,vector(my.MoveSpeed*time_step,0,Gravity),nullvector,glide|ignore_passents|ignore_passable);

wait(1);
}
}




Add it to the bottom of your mainscript file.
Place the model into your level, next to the path and give the patrol_path action to it.

If you get any errors please post them and I will try to fix it, cause I´m to lazy to create my own testlevel (which means, that I haven´t tested the script).

Slin

Re: path scripting [Re: Slin] #127551
05/04/07 02:04
05/04/07 02:04
Joined: Mar 2007
Posts: 69
L
luke_was_ere Offline OP
Junior Member
luke_was_ere  Offline OP
Junior Member
L

Joined: Mar 2007
Posts: 69
Thanks very much for your assistance buddy!

I found a very useful web site which has helped me to solve the problem i faced

i tried the above code but found this error which i have screen shotted for you.


Path scripting web page



Have a good day ppl and i hope to post the game up online sometime so you can see what was achieved of it, peace out x

Last edited by luke_was_ere; 05/04/07 02:07.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1