Monday, June 13, 2011

Unity: Conceptualising Zones

So I'm out and about, enjoying a coffee and snack with Heath, and I start thinking about Zones. Luckily, I have my iPad with me and I can proceed to completely ignore the guy - who is currently, I might add, devouring some tasty looking seasoned chips with sour cream - and take some quick notes.

So the things I know I'm going to want Zones to support:
  1. Region boundaries, defining the visible area in (x,y) of the zone.
  2. The camera's fit-to-zone behaviour, i.e. Whether or not the camera zooms to fit to the zone if the zone is smaller than the camera's visible area.
  3. The camera's boundary behaviour, i.e. If the camera clamps at the boundary, or zooms to attempt to keep the player center frame.
  4. Minimum and maximum zoom extents and the smoothing factor of transitions.
  5. The camera's perspective FOV (for now, static).
  6. The camera's background colour or skybox.
  7. The default overlay colour.
Zones are currently displayed in the world viewport as a simple icon, and when selected, a bounding box. Right now I'm being lazy and attaching a BoxCollider to the Zone just to visualise the Zone's boundaries, but that's unecessarily expensive. I'll remove the BoxCollider and write a custom OnDrawGizmos() method.

I can assign a Zone directly to any Camera by simply dragging and dropping it in the editor. I can also assign Zones to Portals in the same way. When the player arrives at a destination Portal, it assigns its preconfigured Zone to the Camera. This means that currently Zones are hardwired to Portals, but I may take the time later to make Zones more independant and introduce Zone transitions, if I have a need for it. Right now I can only imagine needing Zones on a per-portal basis, but that may change.

Another limitation is that Zones are rectangular only, and I have no clean way to transition between Zones without using a Portal. This makes L-shaped (or T-shaped or anything other than box shaped) levels currently impossible to implement. It gets considerably more complicated binding a Camera to a non-rectangular boundary. At least, for me it does. I could compose more complicated Zone shapes using multiple rectangles, but right now I can't think of an elegant way to handle the transitions across connecting borders.

Worst case scenario isn't so bad anyway, and realistically keeps things nice and simple: Stick to rectangular bounding zones.

No comments:

Post a Comment