Crazy Lasers

Project description

Crazy Lasers is a game created in 8 days during a seminar at the HKU expertise centre. It combines world interaction with motion capture and VR. The game requires two players, one player has to equip a motion capture suit, the other puts on the GearVR. The player with the GearVR has to guide the player with the motion capture suit through an invisible laser maze, the player with the motion capture suit has to follow the instructions and talk with the VR player to navigate to real world buttons to open doors. They can win the game by reaching the end of the without being hit by the lasers.

Challenges
We were going to combine Motion Capture, with VR and world interaction, therefor we faced several challenges. We were using Isadora with bare conductive for projection mapping and world interaction (pressure plates) while using a piece of software written by the hku-ect and motive to stream our motion capture data to the Unity engine. We wanted to give the player in the suit a indication that he got hit by the lasers and died, below is an example of the script, I have removed some irrelevant code for this example.

public class GameManager : MonoBehaviour {

	private OSCClient client;

	// Initialize OSCClient and send GameStart event
	private void Start() {
		client = new OSCClient(IPAddress.Parse("10.200.200.58"), 1234);
	}
       
        // Send a message to Isadora to indicate that the player is killed
	private void GameEndHandler(object sender, string message) {
		SendMessage(1f);
	}

	/// <summary>
	/// Send OSC message to client
	/// </summary>
	/// <param name="value">Value.</param>
	private void SendMessage(float value) {
		OSCMessage m = new OSCMessage("/unity_trigger1");
		m.Append(value);
		client.Send(m);
	}
}

We also wanted the Motion Capture player to open doors within the game by stepping on pressure plates, this meant we also had to send a OSC message to Unity. Luckely hku-ect provided us with a OSCReceiver, so I build a script where the designers could pick the OSC value and check if the gate required two pressure plates (one for the player, one for the audiance). You can see the example below, again I have removed some code as it is irrelevant for this example.
/// <summary>
/// Example of Isadora to Unity communication
/// Handles the opening of laser door when isadora sends a message
/// </summary>
public class GateController : MonoBehaviour {

	public OSCReceiver receiver;
	public bool requiresAudience = false;

	[Range(0, 12)]
	public int oscValue;
	[Range(0, 12)]
	public int audienceOscValue;

	private void Update() {
		GateHandler();
	}
		
	private bool ShouldOpenDoor(float value) {
		return (value == 1);
	}

	/// <summary>
	/// Check if the gate requires multiple buttons to be pressed simultaneously
	/// and open door if the value returns true
	/// </summary>
	private void GateHandler() {
		bool playerOpenGate = ShouldOpenDoor((float)receiver.GetValue(oscValue));
		bool audienceOpenGate = ShouldOpenDoor((float)receiver.GetValue(audienceOscValue));

		if(!requiresAudience) {
			if(playerOpenGate) {
				gameObject.SetActive(false);
			}
		} else {
			if(playerOpenGate && audienceOpenGate) {
				gameObject.SetActive(false);
			}
		}
	}
}

Project details
  • Category : Game Development, Programming
  • Date Created : January 23, 2017
  • Website : Github

Share this Post: