Page 1 of 1

Help to create enemies

Posted: Fri Dec 20, 2019 3:00 pm
by Leonardo2450
I am currently experimenting before starting a project. These days I was thinking about how to create an enemy with a basic artificial intelligence: just follow you. Without a pathfinding system

And I was also thinking of creating several instances of that enemy. The problem is that I don't know how I will do it.

Some help?

Re: Help to create enemies

Posted: Fri Dec 20, 2019 4:05 pm
by pgimeno
That question is pretty broad. "Follow you" can be as simple as go straight towards you as in Drazzard https://love2d.org/forums/viewtopic.php?f=14&t=80655, or as complex as using a path finding algorithm, which is an advanced topic for which a good understanding of graph theory and recursive functions is required. Could you be more specific?

Re: Help to create enemies

Posted: Fri Dec 20, 2019 7:07 pm
by Leonardo2450
pgimeno wrote: Fri Dec 20, 2019 4:05 pm That question is pretty broad. "Follow you" can be as simple as go straight towards you as in Drazzard https://love2d.org/forums/viewtopic.php?f=14&t=80655, or as complex as using a path finding algorithm, which is an advanced topic for which a good understanding of graph theory and recursive functions is required. Could you be more specific?
Hi, without a pathfinding system like in Drizzard.

Re: Help to create enemies

Posted: Fri Dec 20, 2019 7:25 pm
by Ref
This might give you some ideas.
Best

Re: Help to create enemies

Posted: Fri Dec 20, 2019 9:25 pm
by raidho36
To-go pathfinding algorithm is A* (a-star). It's a little complicated but it works great, you don't need to understand it you just need to implement the code without errors. It works great on square and hexagonal grids, but it can also work on a freeform mesh made up of connected dots (navmesh). If your map doesn't have complicated obstacles, you can simply move the object towards the goal and sidestep if it detects obstacles ahead.

Re: Help to create enemies

Posted: Fri Dec 20, 2019 11:24 pm
by Leonardo2450
Ref wrote: Fri Dec 20, 2019 7:25 pm This might give you some ideas.
Best
I'm sorry, I'm still new to Lua and I don't quite understand the code of this project. :/

Edit:
Thank you very much, that gave me an idea and I have done it and it worked. As they would say in my country: Sos un capo