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.
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);
}
}
/// <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;
[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));
if(playerOpenGate) {
gameObject.SetActive(false);
}
}
}