Open rosshadden opened 9 years ago
We should talk about this before either of us implements it, @oppenlander. What I have here is very rough. But I do think we can come up with a powerful set of rules that handles every case we can think of at the time. And based on the above, I actually don't think it will be that difficult!
Pathfinding should probably either be a mixin or a utility. Or perhaps a mixin that uses a utility? :bowtie: :godmode:
I have some great ideas for pathfinding. Just so I don't forget:
Entities with pathfinding should have a target (perhaps a selector, outlined in #16), an awareness radius, and a field of view (angle). If a target is within the awareness radius and inside the FOV, we trigger whatever pathfinding algorithm that entity possesses.
Here are some algorithms I thought up:
A*
.Maybe the second one does everything the first does, and we just make it support different cases, and make the specific algorithm it uses for pathfinding just be the direct path. Actually I like that. So maybe in addition to an
awarenessRadius
, there's also achaseOrForgetRadius
, where an entity stops chasing the target if it gets outside this radius. Then the classic dumb Zelda enemy is supported, as we can make theirawarenessRadius === chaseOrForgetRadius
, and the pathfinding algorithm that they would use in the second step of the above explanation would be to move in a direct line toward the target. And other entities could use different chasing algorithms, likeA*
.