Enemy AI Help

You must understand the Game Editor concepts, before post here.

Enemy AI Help

Postby DrakeStoel » Wed Sep 07, 2016 5:49 am

Hi!

I've been working on programming some enemies, but have run into a couple of problems along the way.

First of all, I want my enemies to move like they're on a grid, 16x16. I have MOSTLY accomplished this. The enemy sprite moves right, left, up, or down like it should, until it just suddenly... Stops. I'm not sure why. I have it set up on a timer. Every time the timer finishes, the code randomly selects an action, moving one of the four directions, using the MoveTo function. going 16 pixels at a time. It is random when the enemy stops moving as well. Sometimes it lasts for thirty seconds, other times it gets stuck right from the get go. Can anyone help with this problem?

Also, a question about further coding. I'm hoping to be able to make my enemy lunge at my player, but only when it is in a certain proximity. I figured that the area can just be a filled region, but how can I make the enemy still always pick the direction that is closest to the player, but still stay on that four directional grid?

Thank you so much in advance! :mrgreen:
DrakeStoel
 
Posts: 43
Joined: Wed Oct 03, 2012 8:53 am
Score: 2 Give a positive score

Re: Enemy AI Help

Postby Zivouhr » Thu Sep 08, 2016 2:03 am

Hopefully one of the experts will offer some advice, but I'll say that the timers aren't always reliable in Game Editor. Sometimes creating a timer within the same object executing the timer can be unreliable to the point the timer won't even start and if it does, it's delayed, so I'll have another object, like the view, create the timer within that object instead of that object creating the timer itself, and it works more reliably.

As far as the player, he needs to have an invisible box region around him (green line box for example would work, parented to the player), and anytime the enemy hits that green box (repeat on or off depending) the enemy attacks (create a command of the enemy attacking when in collision with this player box). Direction the enemy attacks separated by top, down, left or right, with variables if needed.

Some quick ideas any way. Sorry I can't offer more.
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Enemy AI Help

Postby DrakeStoel » Fri Sep 09, 2016 12:30 am

Ok! Thanks for the tip on timers, it works much better now! As for the movement, I'm using a Filled Region as the collision actor and have it set up to have the enemy move in towards my player. This seems to be working pretty well! It's still a little buggy, but I'm pretty certain I'll be able to figure it out.

Thanks for all your help Zivouhr! :mrgreen:
DrakeStoel
 
Posts: 43
Joined: Wed Oct 03, 2012 8:53 am
Score: 2 Give a positive score

Re: Enemy AI Help

Postby Zivouhr » Sat Sep 10, 2016 10:38 pm

DrakeStoel wrote:Ok! Thanks for the tip on timers, it works much better now! As for the movement, I'm using a Filled Region as the collision actor and have it set up to have the enemy move in towards my player. This seems to be working pretty well! It's still a little buggy, but I'm pretty certain I'll be able to figure it out.

Thanks for all your help Zivouhr! :mrgreen:


You're welcome. Glad those tips gave you some ideas of how to tackle this challenge. Best of luck with the game! 8)
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron