// Update is called once per frame void Update() { if (controller == null) { Debug.Log("Controller not initialized."); return; } if (controller.GetPressDown(triggerButton)) { Ray raycast = new Ray(transform.position, transform.forward); RaycastHit hit; bool bHit = Physics.Raycast(raycast, out hit, rayDist, WorldLayer); if (bHit) { int y; string name = hit.transform.gameObject.name; //Debug.Log("Attempting to parse: " + name); if (int.TryParse(name, out y)) { if (isValidGridSpaceName(y)) { interactSpace = WorldConstants.World.GetSpaceFromWorldIndex(y); interactSpace.Dig(); controller.TriggerHapticPulse(500, Valve.VR.EVRButtonId.k_EButton_Axis0); } } } } }
void OnTriggerEnter(Collider collider) { if (!isEnabled) { return; } //Debug.Log("Digging: " + collider.gameObject.name); //DIG! int y; string name = collider.gameObject.name; //Debug.Log("Attempting to parse: " + name); if (int.TryParse(name, out y)) { if (isValidGridSpaceName(y)) { GridSpace interactSpace = WorldConstants.World.GetSpaceFromWorldIndex(y); interactSpace.Dig(); Debug.Log("DUG!"); controller.TriggerHapticPulse(500, Valve.VR.EVRButtonId.k_EButton_Axis0); } } //Menu Interaction else if (name.Equals("New Game - Easy")) { SceneLoader sl = (SceneLoader)GameObject.Find("SceneLoader").GetComponent("SceneLoader"); sl.LoadNewGame(WorldConstants.Scenes.Easy, WorldConstants.Difficulties.Easy); Destroy(collider.gameObject); } }