Unity experiment

Post date: 25-Oct-2012 18:15:26

...the first of many, hopefully. Click here to experience a little Marble Madness.

Valuable lessons learned:

1. My previous clumsy hacks on camera control need to be rewritten - and as is usually the case, the solution was elegantly simple. (I simply move the camera to the ball and then pull back by the desired distance; rotating the camera in response to mouse actions is simple - the only tricky part was picking World rotation for rotation around the 'up' vector, and local rotation for rotation around the 'right' vector, to give a natural orientation.)

2. Adding a damping force made falling look dumb, and surface friction doesn't make any difference to rolling speed - what I needed to tweak to stop it rolling (realistically, but annoyingly) out of control was drag - both the regular and angular kinds.

3. Simple is usually best. For example, the ball moves by apply a force in a direction - the direction is a vector based on the 'forward' direction of the camera. Players don't expect to be pushing 'away' from the camera, though - they expect 'forward' across the terrain (which depending on how steeply down the player is looking, might be a two very different things). So I need to split the camera's forward vector into its vertical and horizontal components - hmm, do I do a Vector3.Project, or something? Simplest solution is to just zero out the 'y' component of the camera vector and renormalise - super simple.

4, Gizmos - super useful. I have a gizmo pointing out of the ball in the direction of force, which makes debugging a heap easier.

UPDATE

I've added some debugging while exploring a Chrome+OSX+WebPlayer bug - turns out to be a known issue regarding that combination.

I've also added cheesy translucency so that terrain doesn't block visibility - I learned a heap about Z ordering, Unity's transparent textures and created my first shader to get this in place - all valuable lessons.