Unity uses state machines for controlling NPCs. I have two states on the enemy at the moment: if the player is a long way away then keep on your course, if the player is close the steer RIGHT AT IT!
That's not a very interesting bit of AI but it helps to test a whole range of things, including collision. Unity uses low poly collision meshes that are generated from your models automatically, which saved me a ton of work.
If two objects have physics components attached to them (called Rigidbody) then when mesh colliders intersect, it applies a physics force at a point, which not only pushes the object but applies torque too.
Before this update, I froze the pitch and roll rotations, so that when you turned at speed, the thing wouldn't tip over. Now I needed the self-righting force (I call buoyancy) because the collision looked weird. I started by turning it off to see what happened. Have a look at the first part of the video and you'll see the collision going, well, not so well.
I knew that I wanted to apply a torque pushing toward the world "Up". I experimented a lot (without reading docs, silly boy) with subtracting vectors and applying them as a torque but that's not how torque works. You pick an axis to rotate around (a 3D vector) and give that vector a magnitude and apply that as torque. The axis you rotate around is the cross product of the world "Up" and the Cloudship's actual "Up". Add some scaling factors to account for the game's internal time and how effective the balloons are (I call lift) and you have a disarmingly simple bit of code.
I buggered about with damping so that it would rock nicely under large collisions and that was it! I was well pleased with myself (second half of the video).
I had a rudimentary shooting script worked out before. You instantiate a cannonball and give it "impulse" force. The cannonball has its own code to detect "colliding with the thing that didn't shoot me" and destroys itself if it does. It will apply damage too but that's for later.
I'm currently just shooting directly at the only enemy at 45 degrees elevation. It's super simple and means you need to keep your distance. When I do Cloudship building, then I want to be able to set where the canons are and the upgrades for the people living on it. That's a way off.
It works for now. To apply the script to the enemy, I needed to produce some of the dirtiest code with fat, nasty if statements. It will all be stripped out but it exists for a while as a nasty pustule (I can't link to it yet as I didn't push the code up).
Taking damage, dying and a very simple menu system. Then, I could argue... it's a game.