This is a quick update on progress of my “update” to Cosmosis. I have got a fair amount done, but find myself falling into the trap I got myself into when I first developed Cosmosis – the “just one more feature” syndrome! I am going to be a lot stricter this time around, and won’t spend too much time updating, but I just had to have homing missiles.
My first try was based on the code I used for a small space shooter prototype I created recently in XNA 4.0. I converted the code across to ObjectiveC / cocos2d and got basic “homing missiles” working in Cosmosis. The problem is they just don’t seem to have that cool “arcing” / “homing” feel to them!
I then stumbled across this excellent resource on basic PID controllers (Part I – Missiles), by a clever guy by the name of Matthew Klingensmith. I had an initial go at implementing his Proportional Controller model for homing missiles, but couldn’t quite get it right. I was lucky enough to get help from him over email and he explained the way it worked over a couple of e-mails and pointed out a couple of errors I had in my initial code attempt. Kudos to Matt!
I was then able to get the model implemented. The end result is this awesome Smart Missile object that I have now sub-classed from CCSprite in cocos2d. Anyway, enough of the talking. Here is a quick video I created of the results. The missiles still need some tweaking to be done, and I have commented out the collision detection so you can see them tracking enemies a little easier (hence the fact that they don’t explode on impact). Oh, I also added a little particle effect to them for their thruster effect, this could also do with a little tweaking.