Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,454 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Following street #276342
07/04/09 15:53
07/04/09 15:53
Joined: Jul 2008
Posts: 170
Germany, near Mainz
Nicotin Offline OP
Member
Nicotin  Offline 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:
Code:
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 laugh

Last edited by Nicotin; 07/04/09 15:55.


Re: Following street [Re: Nicotin] #276348
07/04/09 17:10
07/04/09 17:10
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
are you using the physics engine for the vehicles?

i am not sure what exactly you want to achieve but you could have a look into the python version of knights on wheels (follow the python wrapper link in my signature). it features a simple autopilot mode now which doesn't work too badly considering that it's only a few lines of code.

my racing tracks contain a path and i simply look 3 nodes forward to steer towards that node and i look 10 nodes forward to check if a curve is coming and brake if necessary.

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 Offline OP
Member
Nicotin  Offline 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: Nicotin] #276394
07/04/09 21:12
07/04/09 21:12
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
i am sure it can be fixed somehow but it's unlikely that you will get the solution from anyone because such stuff has to be experimented with. smile

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 Offline OP
Member
Nicotin  Offline 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: Nicotin] #276398
07/04/09 21:32
07/04/09 21:32
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
i don't know the details of a* but can't you put nodes on both lanes and somehow prioritize staying on the same lane in the pathfinding process?

or simply do some calculations to avoid driving towards the center but like i said this needs experimentation and better understanding of your project to find a solution.

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 Offline OP
Member
Nicotin  Offline 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 wink

Last edited by Nicotin; 07/04/09 22:29.



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