by Nathan Whitehouse (nw08)
As of last night, those who boot up the game will find themselves being doggedly perused by a tiny, speedy little box and a lethargic floating capsule. Progress!
The two opponents are able to find the player, orient themselves towards him or her, and move towards them. Movement took a bit of doing, in part because of quaternions being the default form in which object rotations are stored. Thankfully, after much time spent trying to manipulate the quaternions themselves, I found that Unity has some handy functions for those who don’t want to dip into the complex plane. Such as Quaternion.LookAt, which allows easy focusing of an object’s attentions.
The movement portion works, but I’m not sure I completely understand it. For example, the capsule-shaped enemy is set to ignore gravity, causing it to lazily float towards its target (It could quickly float, if I changed the public variable “speed” in the inspector). Because it has a collide, however, if the player jumps on top of it, he can cause it to become ‘destabilized’ and spin about for a moment. Once the capsule has been destabilized, it will usually orient itself right side up again, but will no longer chase the player. Instead, it simply begins to drift towards the heavens, wobbling ever so slightly, until out of sight or shot down mercifully by the player. I don’t know why this happens. It could be the way I’m moving objects isn’t completely right, or it could simply be that physics objects with no gravity act really strangely (so far the cube is well behaved).
I’ve given the enemies a ‘hearing range’ – the player’s presence in a certain radius allows the enemies to chase him. Otherwise they simply wait and listen. Very crude, but it’s a start. I’m working on waypoints – if the enemies don’t know where the player is, they should go to places he might be, or patrol. Also, the enemies should have a vision range in front of them larger than their listening range, should chase a little bit after they can no longer detect the player, and ideally a motionless player will not cause any ‘noise’ for the enemies to hear.
There are also assorted touch ups, including better aiming, easier to edit variables in most functions, and some nice new trees that really ‘spruce’ up the level.