Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (Nymphodora, AndrewAMD, Quad, TipmyPip), 889 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 5 1 2 3 4 5
Re: Tip of the Week #10: New Pathfinding Solution! [Re: Superku] #437689
02/23/14 05:24
02/23/14 05:24
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
A simple function set for Bézier curve "interpolation" has been added as well as integrated directly into the pathfinding. It's not perfect (only 1 node gets interpolated/ smoothed at a time for stability reasons in the pathfinding algorithm) but the entity follows a much smoother path now and it's pretty fast, too:

http://opserver.de/swik10/index.php?title=Pathfinding
http://www.superku.de/HPF_v1.21.zip (updated)



(EDIT: fixed links)

Last edited by Superku; 08/08/15 08:30.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Tip of the Week #10: New Pathfinding Solution! [Re: Superku] #437694
02/23/14 10:06
02/23/14 10:06
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Fixed a few pretty big bugs in the function that calculates the projection of the target position onto the region bounding box (green dot in upper screen), the pathfinding barely/ never worked on bigger areas.
Please download the new version here: http://www.superku.de/HPF_v1.21.zip

Last edited by Superku; 02/23/14 14:49.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Tip of the Week #10: New Pathfinding Solution! [Re: Superku] #437698
02/23/14 14:06
02/23/14 14:06
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Thanks! May come in very handy! laugh


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Tip of the Week #10: New Pathfinding Solution! [Re: alibaba] #446298
10/10/14 07:10
10/10/14 07:10
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
T
tolu619 Offline
Junior Member
tolu619  Offline
Junior Member
T

Joined: Jun 2014
Posts: 97
Lagos, Nigeria
Thanks man! I've just downloaded it. It will save me the trouble of waiting for the current AI series on AUM to be completed before I can learn to add the AI to my racing game laugh

Re: Tip of the Week #10: New Pathfinding Solution! [Re: WretchedSid] #446576
10/21/14 16:53
10/21/14 16:53
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
T
tolu619 Offline
Junior Member
tolu619  Offline
Junior Member
T

Joined: Jun 2014
Posts: 97
Lagos, Nigeria
I'm having problems getting the algorithm to work 100% of the time. I wanted to go through the wiki before posting questions which might have been answered there already. However, whenever I try to go there, it redirects to http://unendliches.net/english/

Re: Tip of the Week #10: New Pathfinding Solution! [Re: tolu619] #446578
10/21/14 17:06
10/21/14 17:06
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Here is the fixed/ new link: http://opserver.de/qwik8/index.php?title=Pathfinding

What kind of errors/ problems are you experiencing? What is the scale of your level/ game, i.e. your characters, choke points and entity speed per tick?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Tip of the Week #10: New Pathfinding Solution! [Re: Superku] #446632
10/23/14 22:24
10/23/14 22:24
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
T
tolu619 Offline
Junior Member
tolu619  Offline
Junior Member
T

Joined: Jun 2014
Posts: 97
Lagos, Nigeria
This error "HPF_PATH_GET: Invalid start/ target node(s)!". How do I check the entity speed per tick? I built a level that's slightly smaller than the "test" level I downloaded with your code and I'm calling up the level from the menu in my game as if it were one of my game's levels. It only has 2 regions and a total of 18 nodes between the 2 paths, and only one AI character. So it's a small level.
My game loads the player into the level, but before now, I hadn't included any NPC in the game. So I put one NPC in my test level and tried to make it so that he finds his way to whatever spot the player was standing when the "t" key was pressed. He should go to that spot even if the player has moved away from the placw. This is the code the AI is running:
Code:
action FollowPlayer()
{
	while(!player)
	wait(-1);
	
	vec_for_min(AIfeet, me); //assigning the lowest position of the model to the vector named "AIfeet"
	
	c_setminmax(my);
	vec_fill(my.min_x,-24);
	vec_fill(my.max_x,24);
	vec_set(PlayerTarget,my.x);
			
	my.skill10 = hpf_path_get_max_nodes(my);
	my.group = 2; // ignore other enemy units when doing pathfinding and visibility calculations (with IGNORE_PUSH)
	
	while(1)
	{
		if(key_t)
		vec_set(PlayerTarget, vector(player.x, player.y, player.z));
		
		my.red = 0;
	 	my.ambient = 0;
	 	my.lightrange = 0;
		
		if(!key_ins) hpf_region_get_target(temp,my,PlayerTarget,HPF_XYZ); //using insert key for dummy if statement
		else vec_set(temp, PlayerTarget);
		hpf_path_draw(my,COLOR_GREEN);
		temp.z = my.z;
		if(vec_dist(temp,my.x) > 16)
		{
			my.red = 100;
	 		my.ambient = 100;
	 		my.lightrange = 100;
	 		
			vec_diff(temp2,temp,my.x);
			vec_to_angle(temp,temp2);
			my.pan += ang(temp.x-my.pan)*0.25*time_step;
			result = c_move(me,vector(maxv(10-0.1*abs(ang(temp.x-my.pan)),0)*time_step,0,0), vector(0, 0, -AIdistancedown),IGNORE_PASSABLE | GLIDE);
			my.skill1 += result;
			my.skill1 %= 100;
			ent_animate(me,"run",my.skill1,ANM_CYCLE);
			
				
	 		//gravity codes		
	 		if(c_trace(my.x, vector(my.x,my.y,my.z-10000), IGNORE_ME|IGNORE_PASSABLE |USE_BOX) > 0)
	   	    AIdistancedown = my.z + AIfeet.z - target.z;
	     	else
	    	AIdistancedown = 0;
	   	
	    	if(AIdistancedown > 0)
	    	AIdistancedown = clamp(AIdistancedown, 0, accelerate(mygravity, 9.8, 0.1)); //0.1 is friction, accelerate "mygravity" by 9.8
	    	//clamp limits distance down to lower limit 0 and upper limit accelerate(mygravity, 9.8, 0.1)
	    	else
	    	{mygravity = 0; vec_set(AILastSolidGround,vector(my.x,my.y,my.z));}
	    	//if Mon is on ground, set gravity to zero and store position of mon on ground
		}
		
		var i;
		for(i = 1; i <= my.skill10; i++)
		{
			path_getnode(my,i,temp,NULL);
			if(vec_to_screen(temp,camera))
			{
				draw_text(str_for_num(NULL,i),temp.x-9,temp.y-9,vector(50,50,50));
				draw_text(str_for_num(NULL,i),temp.x-10,temp.y-10,COLOR_RED);
			}
		}
	
		
		wait(1);
	}
}



Sometimes it works perfectly. At random times, it gives this error "HPF_PATH_GET: Invalid start/ target node(s)!"
On the last few attempts, the whole game would hang without an error message. I can't find any pattern to the problem because the AI finds its way to certain spots perfectly sometimes, then crashes or gives an error at other times when asked to find its way to the same spot.

Re: Tip of the Week #10: New Pathfinding Solution! [Re: tolu619] #446637
10/24/14 09:21
10/24/14 09:21
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Ok. I will get back to you in the next let's say 24 hours.
What I meant with "how big is your level" was not the actual content or size in terms of complexity but the actual quant size because it has only been thoroughly tested in the scale that you see in the demo level (or in my sidescroller where I use the pathfinding all the time and haven't had a single error since).
First guess:
Do you have multiples paths in the level which have the same name?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Tip of the Week #10: New Pathfinding Solution! [Re: Superku] #446652
10/25/14 01:08
10/25/14 01:08
Joined: Jun 2014
Posts: 97
Lagos, Nigeria
T
tolu619 Offline
Junior Member
tolu619  Offline
Junior Member
T

Joined: Jun 2014
Posts: 97
Lagos, Nigeria
No, just path_000 and path_001. I even tested to see whether I could use names like Tpath_000 and Treg_000 but adding any other characters to the path and region names doesn't work with your code. Can you point out what line of code I can go edit so that I can use custom names for my paths and regions?
In WED, quants are represented by the smallest, indivisible cubes when the view is zoomed into 16x8 right? Then my level is about 176 quants wide and 128 quants high. Thanks a lot

Re: Tip of the Week #10: New Pathfinding Solution! [Re: tolu619] #446661
10/26/14 10:19
10/26/14 10:19
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
hpf_region_get_target()
uses region_find() and some string manipulation to determine the appropriate path name. Have a look at line 529 and following:

Code:
str_clip(str_tmp,3);
str_printf(str_tmp,"path%s",_chr(str_tmp));
if(!path_set(ent,str_tmp)) error("HPF_REGION_GET_TARGET: Path to region does not exist!");



Apparently when you want to use Treg_ and Tpath_ as names you will have to adapt the number in str_clip (change it to 4).


Your enemy/ NPC code looks fine to me. hpf_region_get_target() calls hpf_path_get_target() which calculates corresponding start and target nodes which are then used by a subsequent hpf_path_get() call. You could add a
printf("Start: %d, Target: %d, Max_nodes: %d",(int)start_node,(int)target_node,(int)max_nodes);
before the error() instruction in line 216.

Try disabling hpf_path_get_target_collision (in the *.h file) temporarily, too.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Page 3 of 5 1 2 3 4 5

Moderated by  adoado, checkbutton, mk_1, Perro 

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