How to make an ai that goes to a specific point
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How to make an ai that goes to a specific point
Hello! How would I go about making a function that spawns in an ai that can path find and then take that route to the location. The collision method I use is box2d. If there is a way that i could do this without messing with node things that would be great!
Re: How to make an ai that goes to a specific point
Simple way: don't do that, for example don't check the collision or don't use the pathfinding, just wait until the player will be on the straight line to this agent.
For other situations you can use the astar https://en.wikipedia.org/wiki/A*_search_algorithm or any other the pathfinding solutions.
For other situations you can use the astar https://en.wikipedia.org/wiki/A*_search_algorithm or any other the pathfinding solutions.
Re: How to make an ai that goes to a specific point
Spawn agent
Find a path
Move along path
Which bit does your question relate to?
Find a path
Move along path
Which bit does your question relate to?
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/pad-and-pencil-gridiron
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/pad-and-pencil-gridiron
- BrotSagtMist
- Party member
- Posts: 666
- Joined: Fri Aug 06, 2021 10:30 pm
Re: How to make an ai that goes to a specific point
The problem is that box2d isnt really nice for pathfinding.
If you use tiles or a hexagon map pathfinding is just a couple of easy lines. That is because collision is easy there too, we just have to touch tiles till we find the target and then traverse back.
But on free movable objects you can not go around and touch every way possible, that would be an infinitive work.
I other words, that is a complicated task. There are however solutions on this forum for it.
If you use tiles or a hexagon map pathfinding is just a couple of easy lines. That is because collision is easy there too, we just have to touch tiles till we find the target and then traverse back.
But on free movable objects you can not go around and touch every way possible, that would be an infinitive work.
I other words, that is a complicated task. There are however solutions on this forum for it.
obey
-
- Party member
- Posts: 563
- Joined: Wed Oct 05, 2016 11:53 am
Re: How to make an ai that goes to a specific point
You say you want to accomplish this without nodes, but as BrotSagtMist says, pathfinding is easier to do on those nodes. If you can split the map so that it forms a grid, you can use that grid as the basis for the path finding over larger distances. Once the actor is close enough to its goal, you can ignore the grid, and use some other methods, if so desired.
In the end, how to approach this will ultimately depend on how your maps are structured.
In the end, how to approach this will ultimately depend on how your maps are structured.
Re: How to make an ai that goes to a specific point
Nice text about pathfinding and optimization:
https://factorio.com/blog/post/fff-317
https://factorio.com/blog/post/fff-317
Re: How to make an ai that goes to a specific point
I use tiles, there are no curves or anythingBrotSagtMist wrote: ↑Tue Jul 05, 2022 5:37 pm The problem is that box2d isnt really nice for pathfinding.
If you use tiles or a hexagon map pathfinding is just a couple of easy lines. That is because collision is easy there too, we just have to touch tiles till we find the target and then traverse back.
But on free movable objects you can not go around and touch every way possible, that would be an infinitive work.
I other words, that is a complicated task. There are however solutions on this forum for it.
- BrotSagtMist
- Party member
- Posts: 666
- Joined: Fri Aug 06, 2021 10:30 pm
Re: How to make an ai that goes to a specific point
Then why are you stating to use box2d?
Anyway for tiles, i tried writing a tutorial for that a while back:
Anyway for tiles, i tried writing a tutorial for that a while back:
obey
Re: How to make an ai that goes to a specific point
i'm using sti and a script to convert objects into colliders, it's quick and easyBrotSagtMist wrote: ↑Wed Jul 06, 2022 11:35 pm Then why are you stating to use box2d?
Anyway for tiles, i tried writing a tutorial for that a while back:pathfinding.love
Who is online
Users browsing this forum: Ahrefs [Bot] and 10 guests