0 registered members (),
1,454
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Following street
#276342
07/04/09 15:53
07/04/09 15:53
|
Joined: Jul 2008
Posts: 170 Germany, near Mainz
Nicotin
OP
Member
|
OP
Member
Joined: Jul 2008
Posts: 170
Germany, near Mainz
|
Ok, Basic problem: I have a street and want my cars to follow it on the right lane. This already works well but if they come to a curve I can't get to controle them. Here a screen of how they move: I use the A* Pathfinding. So each little bit of street is a own "pattern" the green dots are the centers. And the red arrows are the movement of the car. Here is a part of my code I've already written so the cars drive onto the left or right lane:
vec_add(spur_ziel_vec,vector(0,-cell_size[1]/3,0));
vec_rotate(spur_ziel_vec,my.pan);
//Schaue in Richtung nächster Wegpunkt
vec_set(temp_vec,vector(path_point_x(my.skill1,temp2)+spur_ziel_vec[0],path_point_y(my.skill1,temp2)+spur_ziel_vec[1],my.z));
vec_sub(temp_vec,my.x);
vec_to_angle(my.pan,temp_vec);
vec_fill(temp_vec,0);//"Nulle" den Vektor
// Solange bewegen bis es am Ziel ist
while(vec_dist(my.x,vector(path_point_x(my.skill1,temp2)+spur_ziel_vec[0],path_point_y(my.skill1,temp2)+spur_ziel_vec[1],my.z))>5)
{
//Schaue in Richtung nächster Wegpunkt
vec_set(temp,vector(my.x+car_speed*time_step,my.y,my.z));
vec_sub(temp,my.x);
vec_rotate(temp,vector(my.pan,0,0));
vec_add(my.x,temp);
vec_fill(temp,0);
wait(1);
}
As you may guess the cell_size is the size of the single patterns. So everytime it reaches a waypoint it looks into the direction of the next waypoint, calculated on which lane it has to drive and start moving. I tryed diffrent things with the curves but can't get anything to work. Any suggestions? The second problem is that the car drives into the center of the next streight street-part after a curve. Like seen on the screen. Also btw: Does anyone else got some problems with c_trace in last time? I can't get it to work anymore. It doesn't seem to find entitys anymore even if I exactly know the position of it and trace to it. P.S.: Sorry for my bad english
Last edited by Nicotin; 07/04/09 15:55.
|
|
|
Re: Following street
[Re: ventilator]
#276380
07/04/09 20:18
07/04/09 20:18
|
Joined: Jul 2008
Posts: 170 Germany, near Mainz
Nicotin
OP
Member
|
OP
Member
Joined: Jul 2008
Posts: 170
Germany, near Mainz
|
No, I only use my.x += ......... But the problem is that I have A* now. I had a own code with waypoints first too but it wasn't that good. Also I need the pathfinding for further things. So my main problem is just that my cars doesn't take the curves so well
|
|
|
Re: Following street
[Re: ventilator]
#276397
07/04/09 21:28
07/04/09 21:28
|
Joined: Jul 2008
Posts: 170 Germany, near Mainz
Nicotin
OP
Member
|
OP
Member
Joined: Jul 2008
Posts: 170
Germany, near Mainz
|
I know. The thing is I tryed 500 things and now I don't know even a little bit further anymore. I hoped someone could have a tip or something xD
|
|
|
Re: Following street
[Re: ventilator]
#276401
07/04/09 21:41
07/04/09 21:41
|
Joined: Jul 2008
Posts: 170 Germany, near Mainz
Nicotin
OP
Member
|
OP
Member
Joined: Jul 2008
Posts: 170
Germany, near Mainz
|
The problem is A* is a cell-baes pathfinding. The only node is in the middle of every cell. But, I just got an idea that maybe could finally work xD EDIT: The best ideas comnes while explaining the problem^^ The way I found is a litle bit buggy but I think I'll be able to fix it^^. Thanks anyway for letting me explain
Last edited by Nicotin; 07/04/09 22:29.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|