Any similar enemy ai code with this game?

So I am just curious how to make an enemy follow around the player as the player is moving.

An example is this game: (skip to 0:35)
https://m.youtube.com/watch?v=6M5uFcMweBs

Any similar code out there?
I saw top down shooter and geometry wars but I want more like the example given.

I see (at 0:40):

  • the player walks into a room with enemies
  • the enemies are in a sleep/waiting state
  • As the gate to the room closes the enemies ‘wake’
  • Then enemies seek the player.
  • They also fire at some fixed interval and I’ll assume only when they have and line of sight on the player.

This can be easily coded on your own or with SSK, using:

Or you could see how I do this and make a variant that moves without rotating to face.

That is the essence of it.

By the way.  Geometry wars is pretty much same.  The difference you’re seeing is merely art and animations. 

I assume when you say ‘top down shooter’ you mean this: https://github.com/roaminggamer/CoronaGeek/tree/master/Hangouts/ICanMakeThat/DesktopGames/TopDownShooter

Again, that is essentially the same.

Note: You won’t find a ready-made one-size-fits-all solution. 

Nor, will you find a solution that doesn’t require you to understand how it works and the math behind it. 

(If you do find something like this it will cost big bucks.)

You will have to code this on your own from basic parts available to you or your own custom logic.

I have a ton of examples and code that show similar movement, but using different implementations.

Here is another example, but it will probably be much simpler to grok and modify:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/07/zombieFollow.zip

My suggestion is you examine my examples and others if you can find them, then take them apart.  Tweak them.  Play around till you understand the principles.

There is significant learning involved:

  • some trig concept
  • vector math
  • considerations regarding physics bodies and their behavior
  • overlapping tests and handling
  • understanding of enterFrame and the variability of frame time
  • etc.

@RoamingGamer

Thanks a bunch!

The zombieFollow project was really helpful

Is there anyway to make the enemy transition to the player in a non straight path?

Yes. 

Is there a way to do it automatically?  No.  Gotta come up with your own algorithm on that.  Some kind of zig-zag path and a sequence of transitions if I’m just blue-skying it.

Yah zig-zag path is the word i am looking for.

Tried to look at a bunch transition tips and help pages.

Been trying to do it for a while now.

Ah wait just found this:

https://docs.coronalabs.com/api/library/easing/index.html

looks promising.

  1. I am sure my desktop game example does something like this.  

  2. I modified the zombie follow example to do something like what you’re saying.

(Not to keep pounding on this, but once you understand the concepts and how Corona works, this stuff is pretty straightforward.  So keep experimenting and learning.  Don’t get too focused on a big game.)

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/04/zombieZigZag.zip

https://www.youtube.com/watch?v=vRsLNYko_FE&feature=youtu.be

Another kind of motion you might be thinking of is sinusoidal.  

Old article talks about the math: 

https://gamedevelopment.tutsplus.com/tutorials/quick-tip-create-smooth-enemy-movement-with-sinusoidal-motion–gamedev-6009

Sine_curve_drawing_animation.gif

Ah wow big thanks! This really helps. Thank you so much!

I see (at 0:40):

  • the player walks into a room with enemies
  • the enemies are in a sleep/waiting state
  • As the gate to the room closes the enemies ‘wake’
  • Then enemies seek the player.
  • They also fire at some fixed interval and I’ll assume only when they have and line of sight on the player.

This can be easily coded on your own or with SSK, using:

Or you could see how I do this and make a variant that moves without rotating to face.

That is the essence of it.

By the way.  Geometry wars is pretty much same.  The difference you’re seeing is merely art and animations. 

I assume when you say ‘top down shooter’ you mean this: https://github.com/roaminggamer/CoronaGeek/tree/master/Hangouts/ICanMakeThat/DesktopGames/TopDownShooter

Again, that is essentially the same.

Note: You won’t find a ready-made one-size-fits-all solution. 

Nor, will you find a solution that doesn’t require you to understand how it works and the math behind it. 

(If you do find something like this it will cost big bucks.)

You will have to code this on your own from basic parts available to you or your own custom logic.

I have a ton of examples and code that show similar movement, but using different implementations.

Here is another example, but it will probably be much simpler to grok and modify:

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/07/zombieFollow.zip

My suggestion is you examine my examples and others if you can find them, then take them apart.  Tweak them.  Play around till you understand the principles.

There is significant learning involved:

  • some trig concept
  • vector math
  • considerations regarding physics bodies and their behavior
  • overlapping tests and handling
  • understanding of enterFrame and the variability of frame time
  • etc.

@RoamingGamer

Thanks a bunch!

The zombieFollow project was really helpful

Is there anyway to make the enemy transition to the player in a non straight path?

Yes. 

Is there a way to do it automatically?  No.  Gotta come up with your own algorithm on that.  Some kind of zig-zag path and a sequence of transitions if I’m just blue-skying it.

Yah zig-zag path is the word i am looking for.

Tried to look at a bunch transition tips and help pages.

Been trying to do it for a while now.

Ah wait just found this:

https://docs.coronalabs.com/api/library/easing/index.html

looks promising.

  1. I am sure my desktop game example does something like this.  

  2. I modified the zombie follow example to do something like what you’re saying.

(Not to keep pounding on this, but once you understand the concepts and how Corona works, this stuff is pretty straightforward.  So keep experimenting and learning.  Don’t get too focused on a big game.)

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2018/04/zombieZigZag.zip

https://www.youtube.com/watch?v=vRsLNYko_FE&feature=youtu.be

Another kind of motion you might be thinking of is sinusoidal.  

Old article talks about the math: 

https://gamedevelopment.tutsplus.com/tutorials/quick-tip-create-smooth-enemy-movement-with-sinusoidal-motion–gamedev-6009

Sine_curve_drawing_animation.gif