Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (dr_panther, AndrewAMD, Ayumi, TedMar), 1,033 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
Rating: 5
Page 2 of 4 1 2 3 4
Re: Pathfinding on native Gamestudio graphs [Re: Tai] #290959
09/22/09 16:08
09/22/09 16:08
Joined: Sep 2008
Posts: 68
T
Tai Offline
Junior Member
Tai  Offline
Junior Member
T

Joined: Sep 2008
Posts: 68
Ugh, this is bizarre. When I enter in a dest_node like so

var dest_node = ll_pfind_getClosestNode(my, entTarget.x, 1000, NULL);

it gives me that error. It doesn't seem to like my pointer or something... Because if I use player.x it works fine.

(the pointer is defined exactly the same way it is in your scripts, I've checked.)

EDIT: I got it, finally. When defined as void instead of action, pathfinders can find the object pointed to.

Last edited by Tai; 09/22/09 16:57.
Re: Pathfinding on native Gamestudio graphs [Re: Tai] #290980
09/22/09 18:27
09/22/09 18:27
Joined: Dec 2008
Posts: 271
Saturnus Offline OP
Member
Saturnus  Offline OP
Member

Joined: Dec 2008
Posts: 271
Technically it shouldn't matter if you're using void or action.

However, the last time I checked your script, the movement code could invoke random behaviour, as the you pointer (which was not set) and a var instead of a VECTOR were used. Make sure you ar using something like this:
Code:
VECTOR vec_to_target;
vec_diff(&vec_to_target, &node->pos, &my->x);
vec_to_angle(&my->pan, &vec_to_target);
c_move(my, vector(10 * time_step, 0, 0), nullvector, GLIDE);



Re: Pathfinding on native Gamestudio graphs [Re: Saturnus] #292284
10/01/09 17:44
10/01/09 17:44
Joined: Sep 2008
Posts: 68
T
Tai Offline
Junior Member
Tai  Offline
Junior Member
T

Joined: Sep 2008
Posts: 68
Back again, I had the code working, but when I changed the path substantially or added more enemies pathfinding, it just seized up. Are their any rules regarding node placement, etc?

Re: Pathfinding on native Gamestudio graphs [Re: Tai] #292286
10/01/09 17:58
10/01/09 17:58
Joined: Dec 2008
Posts: 271
Saturnus Offline OP
Member
Saturnus  Offline OP
Member

Joined: Dec 2008
Posts: 271
Hello!

I think I don't quite get the point yet.
Could you explain your problem in more detail?

Re: Pathfinding on native Gamestudio graphs [Re: Saturnus] #303160
12/26/09 06:01
12/26/09 06:01
Joined: Sep 2008
Posts: 68
T
Tai Offline
Junior Member
Tai  Offline
Junior Member
T

Joined: Sep 2008
Posts: 68
Back from the dead here, but I just implemented this without a hitch. My oh my what wonders a little experience does for you. Thanks alot for your help!

Re: Pathfinding on native Gamestudio graphs [Re: Tai] #303213
12/26/09 20:52
12/26/09 20:52
Joined: Dec 2008
Posts: 271
Saturnus Offline OP
Member
Saturnus  Offline OP
Member

Joined: Dec 2008
Posts: 271
Hey,

this is good news, Tai! : )

On another positive note, the code can now also be used without limitation in the free edition of Gamestudio. Previously this wasn't possible as the free edition was lacking WED (which is needed for building graphs).

Re: Pathfinding on native Gamestudio graphs [Re: Saturnus] #303235
12/27/09 02:25
12/27/09 02:25
Joined: Sep 2008
Posts: 68
T
Tai Offline
Junior Member
Tai  Offline
Junior Member
T

Joined: Sep 2008
Posts: 68
I'm at my wit's end here...

It was working; then it stopped.

Code:
action test_pather()
{
	path_set(my, "path_000");
	var start_node = ll_pfind_getClosestNode(my, my.x, 1000, NULL);
	var dest_node = ll_pfind_getClosestNode(my, player.x, 1000, NULL);
	LL_LIST *path = ll_pfind_getPathToTarget(my, start_node, dest_node, ll_pfind_astarCost);
	while(!path)
	{
		beep();
		wait(1);
	}
}



This beeps, which shouldn't be happening.
If I use the full script, I get errors when trying to modify the list; and I get a bit_array error when I compile the full script.

Re: Pathfinding on native Gamestudio graphs [Re: Tai] #303268
12/27/09 16:07
12/27/09 16:07
Joined: Dec 2008
Posts: 271
Saturnus Offline OP
Member
Saturnus  Offline OP
Member

Joined: Dec 2008
Posts: 271
Have you already checked whether the start node and the destination node are valid?

The following line should output their numbers:
printf("start_node: %i | dest_node: %i", (int)start_node, (int)dest_node);

If either of the numbers is equal to zero, the respective node has not been found.

At the moment the pathfinding functions (ll_pfind_getPathTo...) don't check whether the nodes passed as parameters are valid. If both nodes are equal to zero (invalid) the function mistakenly assumes that a path has been found (because current node == destination node). I will fix that, so no list is returned in this case.

Re: Pathfinding on native Gamestudio graphs [Re: Saturnus] #303274
12/27/09 16:31
12/27/09 16:31
Joined: Sep 2008
Posts: 68
T
Tai Offline
Junior Member
Tai  Offline
Junior Member
T

Joined: Sep 2008
Posts: 68
I just tested this out with a different method, just making a while loop to check if they were equal to 0. They don't appear to be equal to zero; however when I use the printf the game freezes when I open it.

Re: Pathfinding on native Gamestudio graphs [Re: Tai] #304120
01/05/10 04:30
01/05/10 04:30
Joined: Sep 2008
Posts: 68
T
Tai Offline
Junior Member
Tai  Offline
Junior Member
T

Joined: Sep 2008
Posts: 68
Hah, I got it working again! I'm not entirely sure what I did though. I reset my level to just a blank square grid with four nodes and it works.

Page 2 of 4 1 2 3 4

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