Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, 7th_zorro, VoroneTZ, HoopyDerFrood), 1,264 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
ASK- How To Make a car follow the path? #401370
05/18/12 00:55
05/18/12 00:55
Joined: May 2012
Posts: 3
amici1897 Offline OP
Guest
amici1897  Offline OP
Guest

Joined: May 2012
Posts: 3
hello.... blush
to the point....i want to ask how to make a car follow the path...i mean, that car, always walking on the path (way) ...on the circle path...
grazie.... blush


true man never leaves his ladies - ale delpiero
Re: ASK- How To Make a car follow the path? [Re: amici1897] #401380
05/18/12 07:12
05/18/12 07:12
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
you need to create a path and move on it by path_spline
http://www.conitec.net/beta/path_spline.htm


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: ASK- How To Make a car follow the path? [Re: sivan] #401383
05/18/12 10:10
05/18/12 10:10
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline

Expert
Realspawn  Offline

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
Code:
#define car_speed skill55
SOUND* aiskids1_wav = "aiskids1.wav";
SOUND* carai1_wav = "carai1.wav";
ENTITY* dummy1;
ENTITY* carai1_dummy;
ENTITY* carai1;
action car_ai()
{
carai1 = my;
var distance = 0;
var previous_pan;
var following_pan;
var min_speed = 20;
var max_speed;
var carai_engine;
var engine_factor;
var dist_z;
var skids_once = 0;
VECTOR last_pos[3];
VECTOR direction[3];
VECTOR temp[3];
max_speed = 35;
dummy1 = ent_create(NULL, nullvector, NULL);
// create another (carai1_dummy) dummy entity that will move on the path
// the ai car will use the same x, y, pan, tilt and roll with the carai1_dummy entity that moves on the path
// but will compute its own z using c_trace; this way, the nodes don't have to be place precisely above the ground
carai1_dummy = ent_create(NULL, nullvector, NULL);
path_set(dummy1, "path_001"); // make sure to name your path this way
engine_factor = 2 + random(2); // start with a random engine sound frecquency each and every time
carai_engine = ent_playloop(carai1, carai1_wav, 300); // start playing the car ai engine sound in a loop
while(1) 
{
previous_pan = carai1.pan;
// place the carai1 entity on the path
path_spline(dummy1, carai1_dummy.x, distance);
distance += dummy1.car_speed * time_step;
// let carai1 look ahead
vec_diff(direction, carai1_dummy.x, last_pos);
vec_to_angle(carai1_dummy.pan, direction);
vec_set(last_pos, carai1_dummy.x);
carai1.pan = carai1_dummy.pan;
carai1.tilt = carai1_dummy.tilt;
carai1.roll = carai1_dummy.roll;
carai1.x = carai1_dummy.x;
carai1.y = carai1_dummy.y;
vec_set (temp.x, carai1_dummy.x);
temp.z -= 2000;
dist_z = c_trace(carai1_dummy.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | IGNORE_MODELS); // ignore the "real" carai
carai1.z = carai1_dummy.z - dist_z + 35; // 35 = experimental value
// sets a variable car ai engine frequency, depending on the speed of the car
snd_tune(carai_engine, 0, dummy1.car_speed * engine_factor, 0); 
wait(1);
following_pan = carai1.pan;
if (abs(following_pan - previous_pan) > 1) // sudden direction change? Then lower the speed of the AI car
{
dummy1.car_speed -= 4 * time_step;
if (skids_once == 0) 
{
skids_once = 1;
if (random(1) > 0.9)
{
ent_playsound(dummy1, aiskids1_wav, 3000);
}
}
}
else
{
skids_once = 0;
dummy1.car_speed += 2 * time_step;
}
dummy1.car_speed = clamp(dummy1.car_speed, min_speed, max_speed);
}
}




Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: ASK- How To Make a car follow the path? [Re: Realspawn] #401993
05/28/12 12:53
05/28/12 12:53
Joined: May 2012
Posts: 3
amici1897 Offline OP
Guest
amici1897  Offline OP
Guest

Joined: May 2012
Posts: 3
grazieeeee.......:))


true man never leaves his ladies - ale delpiero

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | 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