Enemy ai?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- baconhawka7x
- Party member
- Posts: 491
- Joined: Mon Nov 21, 2011 7:05 am
- Location: Oregon, USA
- Contact:
Enemy ai?
My game is a top-view arcade shooter. you are a redbox and you run around and shoot enemies. That's just the problems. the Enemies...So how would i make an enemy that moves in small circles and shoots the enemy?
Last edited by baconhawka7x on Wed Nov 23, 2011 6:18 pm, edited 1 time in total.
Re: Enemy ai?
You should think of what you need and code it. You want the enemy to stand still and shoot the player? Just make him point the player and shoot every X time. You want him to chase the player? Move him directly into the player's position.
It would be easier to tell you about some typical AI approximations if you told us what kind of game is it (platformer, top-down, upshooter, etc).
It would be easier to tell you about some typical AI approximations if you told us what kind of game is it (platformer, top-down, upshooter, etc).
Re: Enemy ai?
Wow, ninja edit here, I didn't realize the update. So, top-view shooter running in circles. It should be something like this:
I haven't tried it but this should work. I'm not sure about the numeric values, I'm not good at thinking with radians and the pixel size depends on your game size, so you may want to experiment a little with this. Remember to initialize the values, probably math.random() should do fine.
Hope it helped, please keep us informed
Code: Select all
for i,e in ipairs(enemyList) do
-- increase the angle on 0.1 radians, bounded to zero and 2pi
e.angle = math.min(math.max(e.angle+0.1, 0), 2*math.pi)
-- update soldier position
-- radius = 30px
e.y = e.y + 30 * math.sin(s.angle)
e.x = e.x + 30 * math.cos(s.angle)
end
Hope it helped, please keep us informed
Who is online
Users browsing this forum: Google [Bot] and 196 guests