In testing Triage, we decided that the static camera setup wasn’t going to cut it for the amount of interaction the player needs with the gurneys. With so many gurneys, the player needs to be able to zoom in where necessary to make sure they have the finer control they need.

The refined camera setup needs to:

  • Allow the player to zoom
  • Allow the player to pan around

For zooming, we have access to Input.GetAxis(“Mouse ScrollWheel”) for measuring the mouse wheel. We also have access to the usual Input.GetAxis(“Vertical”) and (“Horizontal”) for WASD movement (that is also controller-supported!)

Variable Setup:

public class CameraController : MonoBehaviour {
 public float speed; // manage movement speed
 public int maxZoom;
 public int minZoom;
 public int zoomMultiplier; // allow refinement of scrollwheel

Functionality setup:

void Update () 
   if (Input.GetAxis("Horizontal") != 0)
      // Move the player
      float deltaXTransform = ((Input.GetAxis("Horizontal") * speed * Time.deltaTime));

      transform.Translate(deltaXTransform, 0, 0, transform);

   if(Input.GetAxis("Vertical") != 0)
      // Move the player, clamping to required parameters
      float deltaYTransform = ((Input.GetAxis("Vertical") * speed * Time.deltaTime));

      transform.Translate (0, deltaYTransform, 0, transform);

   if (Input.GetAxis("Mouse ScrollWheel") != 0)
         GetComponent<Camera>().orthographicSize = Mathf.Clamp((GetComponent<Camera>().orthographicSize + (Input.GetAxis("Mouse ScrollWheel") * -zoomMultiplier)), minZoom, maxZoom);

Now, the camera is able to zoom and pan using controls players already expect when using top-down cameras. This should mean that players will have a more enjoyable time playing Triage.

Note: due to changes made later in development, this camera setup is now obsolete in favour of our fully-controller supported camera rig.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s