Shooter – Enemy Seperation

My first update in a while… not had chance to do anything else until now 😦

I fixed something that’s been bugging me since I added the chasing enemies (the mines). As they chased the player they would eventually end up piled on top of each other, so I had 50 mines all sitting in a pile chasing the player and it only looked like one mine.

I tried it using propper collision first but that was way too slow for the iDevices, especially as my ultimate gool is to have many things on screen at once trying to hurt the player 😉

In the end I implemnted a A.I flocking method called seperation. Pretty simple really, but for anyone interested: Each entity scans for any other entities within it’s ‘zone’ area and adds a slight pushing-away force from each one, depending on how close.

As they start to clump up they slowly push away from each other without overlapping, but because these forces are ADDED to their original direction, they all still head towards their goal (the player!).

Here’s a couple of screenshots of the mines chasing the player and staying seperated even when clumped on. Note it’s only activated on the MINES here, so ignore the asteroids 😉

I’ve also added a little more debug output as I’m timing updates and renders now to track down slow bits of code early on to keep the framerate nice and smooth 🙂

Oh, the mines can be shot and destroyed now too, which is only fair 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: