Monthly Archives: June 2014

Leave a reply

Unity3D – Fez Style Camera Pan

Put the following script on your camera, setup your 4 waypoints on each “side” of your map, press space and there you go! Make sure to make the camera Orthographic to get the desired effect.

using UnityEngine;
using System.Collections;

public class RotateCamera : MonoBehaviour {

  public float smoothTime = 0.5f;
  public GameObject[] waypoints;
  public int currentWaypoint = 0;

  private bool isChanging = false;

  
  // Update is called once per frame
  void Update () {

    if(currentWaypoint > 3) {
      currentWaypoint = 0;
    }

    if(Input.GetKeyDown(KeyCode.Space) ) {
      if(isChanging) {
        return;
      } else {
        isChanging = true;
        StartCoroutine(DoIt());
        currentWaypoint++;
      }
    }
  }

  IEnumerator DoIt () {
    float i = 0;
    while(i <= 1) {
      i += Time.deltaTime * smoothTime;
      transform.position = Vector3.Lerp(transform.position, waypoints[currentWaypoint].transform.position, i);
      switch(currentWaypoint) {
      case 0:
        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, 0, 0), i);
        break;
      case 1:
        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, -90, 0), i);
        break;
      case 2:
        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, 180, 0), i);
        break;
      case 3:
        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, 90, 0), i);
        break;
      }
      yield return null;
    }
    isChanging = false;
  }
}

facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a reply

Unity3D – In-game Tile Editor Framework

I took some time today and wrote a small bare bones framework that will allow you to create tilemaps in game, save them, and load them later. This is very very basic and not fully featured, but it should be enough to get you started. It was a good learning exercise for me utilizing 2D arrays and keeping them consistent. You can find the code as well as a Unity package containing the project at the link below. Enjoy!

http://xertz.net/unity3d-in-game-tilemap-editor-basic-framework/

facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a reply

His Name Was Jason, And Today Was His Birthday…

In honor of yesterday being Friday the 13th, and my obsession with the Jason slasher films, I decided to whip up this quick little prototype featuring everyone’s favorite camper. Rules are simple: Kill everyone in the map within 10 seconds. You can be spotted by people if you get inside their vision cone, and they can also spot dead bodies. If you get caught or a body is found you must restart the map.

Controls:
Left Mouse Button: Move/Attack
Right Mouse Button: Throw Machete

Enjoy!

http://xertz.net/FridayThe13th/FridayThe13th.html

facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a reply

Unity3D – Calling Coroutines From Static Functions

While rebuilding my messaging system I needed a way to call coroutines from static functions. I have built a static coroutine singleton class that will allow you to do this, as well as have complete control over the coroutine firing ability. The code for this can be found here:
http://xertz.net/static-coroutine-singleton-class/

From there we can easily call coroutines from static functions simply by doing:
StaticCoroutine.DoCoroutine(MyCoroutine());

Enjoy!

facebooktwittergoogle_plusredditpinterestlinkedinmail