Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 975 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
City- / Car Traffic Script #451549
05/11/15 10:37
05/11/15 10:37
Joined: May 2012
Posts: 22
Germany, Deutschland
G
Gamingtypen Offline OP
Newbie
Gamingtypen  Offline OP
Newbie
G

Joined: May 2012
Posts: 22
Germany, Deutschland
Hello, guys!
Im currently trying out some possibilities of writing a functional path-following car-script. The car should follow the nearest path using c_move(). If there are multiple paths avaible, it should randomly choose one. This should simulate traffic in a city.
So, how can I do that? Thanks for helping. laugh

Guten Tag.
Ich probiere zurzeit verschiedene Möglichkeiten eines Fahrzeugs aus, welches später mal mithilfe von Pfaden einen Weg durch eine Stadt finden sollte.
Dabei möchte ich, dass das Fahrzeug anfangs zum nähesten Knoten teleportiert wird und an Kreuzungen beispielsweise eine zufällige Route einschlägt.
Kollision sollte weiterhin vorhanden sein, dass Auto sollte schlicht und einfach per c_move() bewegt werden.

Das ist für mich nicht unbedingt neu, dass habe ich schon mehrmals versucht. Wirklich hinbekommen habe ich es bisher aber nicht, eventuell könnt ihr mir helfen?
Danke im Vorraus. laugh

Re: City- / Car Traffic Script [Re: Gamingtypen] #451556
05/11/15 13:49
05/11/15 13:49

M
Malice
Unregistered
Malice
Unregistered
M



Start with car_Ai from AUM 33 and on. It is what I modified to write a old race track ai. If you need more help with specific instructions PM me or ask here.


Take a look at this poor code I've used
Code:
action car(){
wait(random(3)); // Randomize first selection AI_ENT
	track_select=1; // GLOBlE NOTICE
	if(track_select >1)
	track_select = 1;
	if(track_select ==1)
	path_set(my,"path_000");
	if(track_select ==2)
	path_set(my,"path_001");
	if(track_select ==3)
	path_set(my,"path_002");
	if(track_select ==4)
	path_set(my,"path_003");
	if(track_select ==5)
	path_set(my,"path_004");
	if(track_select ==6)
	path_set(my,"path_005");
	if(track_select ==7)
	path_set(my,"path_006");
	if(track_select ==8)
	path_set(my,"path_007");
	if(track_select ==9)
	path_set(my,"path_008");
	/////////////////////////////////////////////////////////////////////
	
	my.NODE_NEXT=path_nextnode(my,1,1); // SET THE NODE
	while(1)
	{
         // PATH NODE DETECTION AND RANDOMIZATION AND FACING //////////////////////////////////
		
		
		if(vec_dist(my.x,vec_next_node.x) < my.max_x)    // Is next node within 160 units 
		{
			path_next(my); // will jump from current path to new path// Jump to new path
			my.NODE_NEXT=path_nextnode(my,my.NODE_NEXT,1); // Grab Next node on new path -- NOTE ALL PATHS MUST HAVE THE SAME NUM NODE IN SAME GEN LOCATION
			my.skill10=0; // only enable facing the path node if changing the path.   
		}
		
		path_getnode(my,my.NODE_NEXT,vec_next_node,NULL);  // Get next node actual vector location 
		
		if(my.skill10 ==0)
		{
			vec_to_angle(my.pan,vec_diff(NULL,vec_next_node,my.x)); // face the new node
		}

		///////////////////////////////////////////////////////////////////////////
		
		// SOFT AND HARD MOVEMENTs /////////////////////////////////////////////////////////////
		
		c_move(my,vector(my.skill3*time_step,0,0),nullvector,GLIDE | IGNORE_PASSABLE);
		
wait(1);
}
}


Last edited by Malice; 05/11/15 14:06.

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

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