The Start of Pathfinding! (Ongoing Project)

Hello everyone,

I know many people have been trying to make games with pathfinding, and I created a project that may be used to eventually, make a pathfinding game with an entity and a player.

This is the shared project:

Right now, there is only room detection with the game knowing exactly where everything is, but we can simply add path points to tell the entity to move depending on the room the entity and the player is in. The only problem with this, though, is that it would just be too much to just add an “if” block for every single possible combination of the current room positions. Is there anyone who has a better way to tell the entity to move instead of adding tens of “if” blocks?

Thanks!

5 Likes

Good idea @Bladebob20000 - this will be useful for indoor spaces. Here’s my contribution - a simplification of the collision code: CoSpaces Edu :: Remix of Pathfinding v1.1 (room detection) demo

What’s your next step?

2 Likes

Hi @techleapnz and to the community!

I have really scratched my head about this, and my final ideas were;
this idea can branch off in two ways. One involves making the AI move in a one-way direction depending on which room the AI is currently in. This method was inspired by a scratch pathfinding tutorial, and I think we could be able to make a similar version on cospaces. However, this would create complications for the game as it will only allow the AI to move in one way, and would not be able to go to a specific updated point. (If anyone has an idea of how to guide the “one way” to make it move towards an updated spot, such as the player, please let me know). The second method will involve moving the AI across random rooms in the guided path (this can be randomized with a random number block) and making the AI look toward you and chase you when the room number and the player number match, seeing that will mean you and the AI is within sight.

In conclusion, none of these methods I mentioned is a direct solution to pathfinding, and will not work for people looking for ways to make a perfect pathfinding AI or entity travel to the player with the shortest route. As always, I am always looking for any ideas that can be an alternative solution to this and I encourage all of you all to make a post for anything that can be a potential contribution to this idea that has been though of for months, maybe years. Thanks!

Link to pathfinding tutorial for scratch (basically cospaces on a 2d engine):

PS: (I’m working on remixable projects for the methods I mentioned above, I’ll probably be finished in a few days or more)

2 Likes

Hi, I had already worked on it successful in the past and I think we can create something like that in CoSpaces, I will work on it in this afternoon (Italian time zone). Hope also @techleapnz or another expert of CoSpaces will work on it

2 Likes

Hello, I worked about pathfinding and I think I reach the best solution for an AI that moves through some rooms.
But unfortunaly the system doesn’t work probably because the collisions commands in the function doesn’t run, anyone have the solution of this problem?

This is my project:

However, the system consists in making a fuzione that moves four cubes in two directions and two lines of x and y (simply forward, backward, right and left), the last of the cubes to reach an element of the group “walls” will be the direction towards which the main element will move and then restart the function repeating the whole, maybe solved the problem of collisions you could work on counteracting the inevitable loops that will create (perhaps by keeping track of the path taken by the main element using another function).

2 Likes

I think we are already at a good point, let’s see what @techleapnz thinks.

2 Likes

Hi team, I think we need to be very clear about the scope of the pathfinding:

  1. Are we wanting to build a 2D pathfinding system for a maze-like environment (like in the Scratch tutorial), or a 3D path-finding system that works in any environment?

  2. Does the pathfinding system have to behave in the same way as the Scratch system, or can we use alternative means (such as following the Camera)?

  3. Is it for a single entity or multiple?

  4. Should the path-finding start straight away or be triggered by “seeing” an entity?

It’s easy to create something that fulfills some criteria, but difficult to create something that looks really good.

1 Like

@techleapnz I think this idea if fixed could be used in all ways (2D and 3D adding two more cubes).
For the other things let’s see what @Bladebob20000 thinks.

1 Like

I hope you’re having a great day @techleapnz!

Yes, sorry I haven’t been clear on this. First, my goal for this project is to create a way for a single entity to pathfind to the player. I am thinking of this as a 3d environment, so less experienced builders can make their own projects or game with a simple pathfinding template. And, to clarify, I used the scratch tutorial to create an example of an alternative similar way for the entity to move. For your fourth question, this honestly depends on what project someone is trying to make, but I think sticking to straight-away pathfinding will be much easier to understand and we can always adapt afterward. Here is an example of a game I imagine to be able to create if we finish this project; There could be an escape room “horror” game where an entity will chase the player (if possible, maybe multiple elevated environments such as a two-story house?) around the map and the player must solve puzzles to escape while at the same time avoiding the enemy. That’s all I have on my criteria for now!

Thanks!

1 Like

I’m pretty busy at the moment, but if I have a moment, I’ll have a go at trying a couple of pathfinding options.

So, @Alessio_Bonini, I like your idea - so the chaser sends out cubes (like sonar) to navigate the world. This currently assumes a perfectly square grid maze. To solve this, we could create a single function to send out a block to scan the world in a single direction, then do that in all directions, make a note of 1st collision position, and send the chaser to the position.

This way is teach the AI to find it’s own way to get to the player; the Scratch way is to tell the AI where to go.

2 Likes