pathfinding questions...
- azekill_DIABLO
- Member
- Posts: 7507
- Joined: Wed Oct 29, 2014 20:05
- GitHub: azekillDIABLO
- In-game: azekill_DIABLO
- Location: OMICRON
- Contact:
pathfinding questions...
hello! i will be short: how to make a mob follow a path? (oh btw, how to properly store the path in an entity :D) thx!
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
Re: pathfinding questions...
There are two ways to follow a path. The simple one is to move from node to node. If the mob is close enough select the next node as target.
A bit more complicated is it to calculate the nearest segment and move along the path, but you need some vector calculation for this.
The problem of the first way is, that if you miss a target node, e.g. because the mob continues moving while the code lags, the mob turns around and moves back
A bit more complicated is it to calculate the nearest segment and move along the path, but you need some vector calculation for this.
The problem of the first way is, that if you miss a target node, e.g. because the mob continues moving while the code lags, the mob turns around and moves back
- azekill_DIABLO
- Member
- Posts: 7507
- Joined: Wed Oct 29, 2014 20:05
- GitHub: azekillDIABLO
- In-game: azekill_DIABLO
- Location: OMICRON
- Contact:
Re: pathfinding questions...
Can you show me a sample of code using minetest.find_path? (or your WIP pathfinding if you prefer)
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
Re: pathfinding questions...
I'm not at home, so I can't you show my code. But you can search for steering behaviours pathfinding.
That's what I use in my videos
That's what I use in my videos
Re: pathfinding questions...
You have seen smart mobs ?azekill_DIABLO wrote:how to make a mob follow a path?!
'My' wiki-pages: Build-a-home - basic-robot - basic_robot_csm - basic-machines - digtron - xdecor -
Map-Database
Map-Database
- azekill_DIABLO
- Member
- Posts: 7507
- Joined: Wed Oct 29, 2014 20:05
- GitHub: azekillDIABLO
- In-game: azekill_DIABLO
- Location: OMICRON
- Contact:
Re: pathfinding questions...
Sure, i will dig into the code.
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
- azekill_DIABLO
- Member
- Posts: 7507
- Joined: Wed Oct 29, 2014 20:05
- GitHub: azekillDIABLO
- In-game: azekill_DIABLO
- Location: OMICRON
- Contact:
Re: pathfinding questions...
okay still don't get it LOL.
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
Re: pathfinding questions...
How do you get/calculate that path ?azekill_DIABLO wrote:how to make a mob follow a path?
Can it change, how do you update ?
Is it just one mob, or several ?
Can they block each other, who gets to move first ?
'My' wiki-pages: Build-a-home - basic-robot - basic_robot_csm - basic-machines - digtron - xdecor -
Map-Database
Map-Database
Re: pathfinding questions...
https://github.com/sofar/entity_ai/blob ... th.lua#L86azekill_DIABLO wrote:okay still don't get it LOL.
you store the path in the entity luaobject, essentially.
- azekill_DIABLO
- Member
- Posts: 7507
- Joined: Wed Oct 29, 2014 20:05
- GitHub: azekillDIABLO
- In-game: azekill_DIABLO
- Location: OMICRON
- Contact:
Re: pathfinding questions...
Okay for this... and then how to make him follow that?
oh and BTW, where i should define self.path? in on_activate?
EDIT: https://github.com/sofar/entity_ai/blob ... h.lua#L109
that it no, to make the mob follow? it's so complicated!
oh and BTW, where i should define self.path? in on_activate?
EDIT: https://github.com/sofar/entity_ai/blob ... h.lua#L109
that it no, to make the mob follow? it's so complicated!
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
Re: pathfinding questions...
remember that entities in minetest are luaentities, and you can put any information into them - they're essentially tables that have no restrictions.azekill_DIABLO wrote:Okay for this... and then how to make him follow that?
oh and BTW, where i should define self.path? in on_activate?
EDIT: https://github.com/sofar/entity_ai/blob ... h.lua#L109
that it no, to make the mob follow? it's so complicated!
entity_ai abstracts the path finding and the path following code into the path class code you looked at. The path:step code is executed every entity on_step() callback to move the entity to the next point in the path. It all looks very complex because it is - this is the reason I developed entity_ai in the first place - nobody can really develop all the bits that are needed to make good entities. But if you make a good abstraction, people can work on the separate parts of it and make something fantastic together...
- azekill_DIABLO
- Member
- Posts: 7507
- Joined: Wed Oct 29, 2014 20:05
- GitHub: azekillDIABLO
- In-game: azekill_DIABLO
- Location: OMICRON
- Contact:
Re: pathfinding questions...
i'm going to melt my brain with all of this. Thanks!
*coding*
*coding*
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
- azekill_DIABLO
- Member
- Posts: 7507
- Joined: Wed Oct 29, 2014 20:05
- GitHub: azekillDIABLO
- In-game: azekill_DIABLO
- Location: OMICRON
- Contact:
Re: pathfinding questions...
Wiow, it really helps me! thank you again!
but I have a problem i can't solve... If the returned self.path is a table of successive postitions; self.path[1] should return a pos no? i have no idea how to extract the different postition from the path... can you help me?
but I have a problem i can't solve... If the returned self.path is a table of successive postitions; self.path[1] should return a pos no? i have no idea how to extract the different postition from the path... can you help me?
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
- azekill_DIABLO
- Member
- Posts: 7507
- Joined: Wed Oct 29, 2014 20:05
- GitHub: azekillDIABLO
- In-game: azekill_DIABLO
- Location: OMICRON
- Contact:
Re: pathfinding questions...
*bump*
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
Re: pathfinding questions...
in entity_ai I just look at the "next" step. And once an entity is "close enough" to that step, it is removed from the table. Then the next iteration will just look at the step after that, since that is now the "next" step. Until the path is empty.azekill_DIABLO wrote:Wiow, it really helps me! thank you again!
but I have a problem i can't solve... If the returned self.path is a table of successive postitions; self.path[1] should return a pos no? i have no idea how to extract the different postition from the path... can you help me?
https://github.com/sofar/entity_ai/blob ... h.lua#L121
- azekill_DIABLO
- Member
- Posts: 7507
- Joined: Wed Oct 29, 2014 20:05
- GitHub: azekillDIABLO
- In-game: azekill_DIABLO
- Location: OMICRON
- Contact:
Re: pathfinding questions...
It wasn't what i looked for, sorry, but thanks. I'm asking if it's possible to get, for example the position of the third step of the path as a table.
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
- azekill_DIABLO
- Member
- Posts: 7507
- Joined: Wed Oct 29, 2014 20:05
- GitHub: azekillDIABLO
- In-game: azekill_DIABLO
- Location: OMICRON
- Contact:
Re: pathfinding questions...
Code: Select all
local nextpos = next(path)
print(nextpos)
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
Re: pathfinding questions...
`next` returns `index, value` from the table (path).azekill_DIABLO wrote:returns '1'. What?Code: Select all
local nextpos = next(path) print(nextpos)
So you should do:
nextindex, nextpos = next(path)
print(nextindex, minetest.pos_to_string(nextpos))
- azekill_DIABLO
- Member
- Posts: 7507
- Joined: Wed Oct 29, 2014 20:05
- GitHub: azekillDIABLO
- In-game: azekill_DIABLO
- Location: OMICRON
- Contact:
Re: pathfinding questions...
oh thank you!! I was totally unuware you could do such a thing, and that why I was lost when looking at you API... I will not forget ;)
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!
DMs are always open if you want to get in touch!
Who is online
Users browsing this forum: Google [Bot] and 7 guests