enemy ai movement.

hi,
am doing a space shooter game, in which i want the enemy to move in a zig zag movement, (i.e) it has to move forward and at the same time it has to move left and right. i have tried with physics, but this time i dont want to do it with physics. a basic outline of how to achieve will do great.

Hey bud, here is a complete package that i put together.

It translates and rotates the object through a set of waypoints (you can move these to whereever, you like.
have a play about with it and see what you come up with)

note: this uses quaternions also to rotate the object tracking the way points towards that waypoint`s local forward.

if you download the zip, unzip and add this custom package to a unity project and run the scene included, you will see the result.

I am guessing you will be wanting to create some sort of state system to handle your enemy AI
for that i would create an empty parent(as can be found in the package scene)and i would prefab it out so that the scripts and way points are always inside (or childed) your enemy game object.

This way , when you create said FSM(or such like) when an enemy state was invoked or something like that, your enemy could just start patrolling the waypoints…until it saw you or something that might change its current state if ya get me (this is totally totally totally another subject though - FSMs i mean)
Anyway, here`s package with scene and all code - enjoy and if you think it has helped you mark it an answer as i think this might help others too…especially as its a convenient package demonstration etc.

Below is a Link to a Dropbox folder where you can download the package as unity Answers doesn`t seem to be giving me any other options except to answer in text only, n all that.

LINK (copy below URL and paste in browser address bar to get to package)

https://www.dropbox.com/sh/hmn4ax6swykktf7/TuzjsQp-Un

LINK

Merry non-denominated holiday!
Thanks for reading.
Gruffy :slight_smile: