Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / [request] Path and pathfinding

Author
Message
Zigi
14
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 3rd May 2019 07:59 Edited at: 3rd May 2019 08:27
//EDIT: it is 2D path and 2D pathfinding. Forget to mention in the title.
Could be also 3D but I am after 2D now in the first place.

It is a feature that very often pop-up when I consider which engine to use for my projects and AppGameKit almost always comes up on top like now with Studio in mind to be released in June. But then because there is no solution offered for path and pathfinding I usually go with something else.
With the new scene editor, it would be a great opportunity to also include a "path editor" that could integrate with the scene editor. In short, the idea is very similar to one we have in FPSC and GameGuru. We could predefine paths by simply drawing lines and tell sprites to move on the selected path to the end or back and forth or random. We could use the IDE to set this up and use code like MoveOnPath(pathID, mode, speed) to launch a sprite to move on the selected path.

Pathfinding is something that I see to come up on the forum since day 1 and sorry to see that it have been not addressed in Classic. But I'm here the suggest to add some sort of pathfinding solution to Studio. Pathfinding is something that many genre of games do require when we would like to allow sprites to find their own way from point A to point B and avoid obstacles. The way it could work in Studio, sprites could have a property if they are obstacles of pathfinding or not and could have an other property for selecting if a sprites using pathfinding to navigate. If a sprite is using pathfinding, we could have further options to set the speed of movement, if angle rotate toward direction of movement and if the path is smooth or not meaning if the path cut corners or not. Once we have set all this, in Tier1 we could launch a sprite to move from point A to point B while also avoid the obstacles.

Commands we could have:
FindPath(spriteID, startX, startY, targetX, targetY) //return a path ID if path found 0 if no path is available
MoveOnPath(pathID, mode, speed) //could be the same command we use with paths drawn in the scene editor since the FindPath() command return an ID but could use a separated command in case FindPath() simply return if path found to point or not.
EndOfPathReached(psriteID) //return 1 if the sprite reached the end of the path
IsMovingOnPath(spriteID) //return 1 if the sprite currently moving on path

Of course the entire process to setup a sprite to use pathfinding or be an obstacle could also be exposed to Tier1 so people prefer not to use the scene editor can still take advantage of the pathfinding too.

More advanced option could be also to be able to set cost of obstacles. It means the path can nove through the obstacle but it is going to slow the movement down and the pathfinding going to prefer the obstacle with the lower cost.
For example we could set the mud to be cost of 3, water to be cost of 2 and a log over the river to be cost 1 and a bridge over the river cost 0. So the pathfinding would prefer in order 0:bridge, 1:log, 2:water, 3:mud. So we could choose if an obstacle have a cost or solid.

I think it would be extremely useful and important for AppGameKit to have since many competitors do offer a solution for 2D navigation.
Thanks.

Login to post a reply

Server time is: 2024-04-18 23:39:47
Your offset time is: 2024-04-18 23:39:47