public override void OnControllerEnter(PlayerViveController currentController) { base.OnControllerEnter(currentController); if (m_Toggled == false) { m_Toggled = true; if (currentController != null) { var source = currentController.GetCurrentHand(); currentController.Vibration(0, 0.7f, 10, 1, source); } GetComponent <AudioPlayer>().Play(); GetComponent <Renderer>().material.SetColor("_Color", Color.green); m_Train.GetComponent <TrainArriver>().BeginArrival(() => { transform.Find("AnnouncementBeep").GetComponent <AudioPlayer>().Play(); }); transform.DOLocalMoveX(m_ToggleOffset, 0.2f).SetRelative(); } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Player") { FindObjectOfType <PlayerDeathHandler>().KillPlayer("death_trainjump"); } else if (other.tag == "Bomb") { PlayerViveController.GetControllerThatHolds(other.gameObject)?.DetachCurrentObject(false); other.gameObject.GetComponent <Bomb>().ThrownOut(); PushObjectAway(other.gameObject); } else if (other.tag == "Doll") { PlayerViveController.GetControllerThatHolds(other.gameObject)?.DetachCurrentObject(false); other.gameObject.GetComponent <Doll>().OnThrownOut(); PushObjectAway(other.gameObject); } else if (other.gameObject.GetComponent <Rigidbody>() != null && other.gameObject.GetComponent <IInteractable>() != null) { PlayerViveController.GetControllerThatHolds(other.gameObject)?.DetachCurrentObject(false); PushObjectAway(other.gameObject); } }
public override void OnControllerEnter(PlayerViveController currentController) { base.OnControllerEnter(currentController); playerController = currentController; playerHand = playerController.GetCurrentHand(); }
private void OnTriggerEnter(Collider other) { if (other.tag == "SawBlade") { var saw = other.GetComponentInParent <SawBlade>(); var isSpinning = saw?.IsSpinning(); if (!isSpinning.Value) { return; } OpenCompartment(false); GetComponent <AudioPlayer>().Play("openlock"); GetComponent <CapsuleCollider>().enabled = false; saw.SawUnLock(); } else if (other.tag == "SmallKey") { GameObject key = other.gameObject; // Play lock key sound. GetComponent <AudioPlayer>().Play("openlock"); OpenCompartment(); PlayerViveController.GetControllerThatHolds(other.gameObject).DetachCurrentObject(false); Destroy(other.gameObject); GetComponent <CapsuleCollider>().enabled = false; } }
public override void OnControllerEnter(PlayerViveController currentController) { base.OnControllerEnter(currentController); bCanGrab = true; PlayerHand = currentController.gameObject; _outline.enabled = true; }
public override void OnControllerEnter(PlayerViveController currentController) { base.OnControllerEnter(currentController); if (DriverCabinDoorLock.bIsUnlocked && !bBrakeIsStuck) { bCanGrab = true; PlayerHand = currentController.gameObject; } }
public override void OnControllerEnter(PlayerViveController currentController) { base.OnControllerEnter(currentController); if (!bIsLocked) { bCanGrab = true; } PlayerHand = currentController.gameObject; }
private IEnumerator NewspaperBurnEffect() { while (burnOutTime >= Time.time) { paperTextureColor.r -= 0.004f; paperTextureColor.b -= 0.004f; paperTextureColor.g -= 0.004f; paperMaterial.color = paperTextureColor; yield return(new WaitForSeconds(0.1f)); } burningAudio.Stop(); Instantiate(burnoutParticle, transform.position, transform.rotation, null); PlayerViveController.GetControllerThatHolds(gameObject)?.DetachCurrentObject(false); Destroy(gameObject); }
public override void OnControllerEnter(PlayerViveController currentController) { base.OnControllerEnter(currentController); if (bIsBroken) { return; } if (ActivateCount >= BreakAtCount) { ownedLights.bIsOn = true; ownedLights.ToggleLights(); bIsBroken = true; bSwitchIsOn = false; var rigidbody = transform.GetComponent <Rigidbody>(); rigidbody.useGravity = true; rigidbody.isKinematic = false; rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous; bCount = true; return; } Audio.Play(); var source = currentController.GetCurrentHand(); currentController.Vibration(0, 0.2f, 5, 1, source); if (bSwitchIsOn) { bSwitchIsOn = false; transform.localRotation = Quaternion.Euler(0, 0, -90); ownedLights.ToggleLights(); } else { bSwitchIsOn = true; ActivateCount += 1; transform.localRotation = Quaternion.Euler(0, 0, 0); ownedLights.ToggleLights(); } }
public void InsertHandle(EmergencyDoorHandle handle) { var controller = PlayerViveController.GetControllerThatHolds(handle.gameObject); if (controller != null) { controller.DetachCurrentObject(false); } handle.SetHolder(this); handle.GetComponent <Rigidbody>().useGravity = false; handle.GetComponent <Rigidbody>().isKinematic = true; handle.transform.position = transform.position; handle.transform.rotation = transform.rotation; GetComponent <AudioPlayer>().Play("handleclicked"); handle.inserted = true; }
private void OnTriggerEnter(Collider other) { if (other.tag == "GlassFragment") { var controller = PlayerViveController.GetControllerThatHolds(other.gameObject); // Check if player is holding the glass and a piece hasn't just randomly landed on the wire collider if (controller != null && controller.gameObject.GetComponent <SteamVR_Behaviour_Pose>().GetVelocity().magnitude >= heldCutForce) { WireCut(); } } else if (other.tag == "SawBlade" && other.GetComponentInParent <SawBlade>().IsSpinning()) { WireCut(); } else if (other.tag == "Scissors") { WireCut(); } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Extinguisher" || other.tag == "BaseballBat" || other.tag == "BowlingBall") { var controller = PlayerViveController.GetControllerThatHolds(other.gameObject); if (controller == null) { if (other.gameObject.GetComponent <Rigidbody>().velocity.magnitude >= thrownBreakForce) { BreakGlass(); } } else { if (controller.gameObject.GetComponent <SteamVR_Behaviour_Pose>().GetVelocity().magnitude >= heldBreakForce) { BreakGlass(); } } } }
public override void OnControllerEnter(PlayerViveController currentController) { base.OnControllerEnter(currentController); Controller = currentController; }
public virtual void OnControllerEnter(PlayerViveController currentController) { }
private void OnCollisionEnter(Collision collision) { if (transform.gameObject.name == "polySurface3157") { if (!sawBlade.IsSpinning()) { return; } if (collision.gameObject.tag == "Band") { newHandleObjects = new List <GameObject>(); collision.gameObject.tag = "Untagged"; originalHandleParent = collision.gameObject.transform.parent.gameObject; grabHandle = collision.transform.GetChild(0).gameObject; ContactPoint contact = collision.contacts[0]; newHandleObjects.AddRange(CutMesh(collision.gameObject, contact.point, transform.right, collision.gameObject.GetComponent <Renderer>().material, true)); for (int i = 0; i < newHandleObjects.Count; ++i) { newHandleObjects[i].gameObject.tag = "Untagged"; newHandleObjects[i].transform.parent = originalHandleParent.transform.root; Destroy(newHandleObjects[i].GetComponent <MeshCollider>()); newHandleObjects[i].AddComponent <BoxCollider>(); } RaycastHit hit; Physics.Raycast(originalHandleParent.transform.position, Vector3.down, out hit); UpperPart = hit.collider.gameObject.name; if (UpperPart == newHandleObjects[0].name) { newHandleObjects[0].transform.parent = originalHandleParent.transform; } else { newHandleObjects[0].layer = LayerMask.NameToLayer("Default"); newHandleObjects[0].AddComponent <Rigidbody>(); grabHandle.GetComponent <ConfigurableJoint>().connectedBody = newHandleObjects[0].GetComponent <Rigidbody>(); grabHandle.transform.parent = newHandleObjects[0].transform; grabHandle.AddComponent <Ball>(); Destroy(newHandleObjects[0].GetComponent <ConfigurableJoint>()); } if (UpperPart == newHandleObjects[1].name) { newHandleObjects[1].transform.parent = originalHandleParent.transform; } else { newHandleObjects[1].layer = LayerMask.NameToLayer("Default"); newHandleObjects[1].AddComponent <Rigidbody>(); grabHandle.GetComponent <ConfigurableJoint>().connectedBody = newHandleObjects[1].GetComponent <Rigidbody>(); grabHandle.transform.parent = newHandleObjects[1].transform; grabHandle.AddComponent <Ball>(); Destroy(newHandleObjects[1].GetComponent <ConfigurableJoint>()); } } } else if (transform.gameObject.tag == "GlassFragment") { var controller = PlayerViveController.GetControllerThatHolds(transform.gameObject); // Check if player is holding the glass and a piece hasn't just randomly landed on the wire collider if (controller != null && controller.gameObject.GetComponent <SteamVR_Behaviour_Pose>().GetVelocity().magnitude >= heldCutForce) { if (collision.gameObject.tag == "Wire") { collision.gameObject.tag = "Untagged"; ContactPoint contact = collision.contacts[0]; newHandleObjects.AddRange(CutMesh(collision.gameObject, contact.point, transform.right, collision.gameObject.GetComponent <Renderer>().material, false)); newHandleObjects[0].tag = "Untagged"; newHandleObjects[1].tag = "Untagged"; } else if (collision.gameObject.tag == "Band") { newHandleObjects = new List <GameObject>(); collision.gameObject.tag = "Untagged"; originalHandleParent = collision.gameObject.transform.parent.gameObject; grabHandle = collision.transform.GetChild(0).gameObject; ContactPoint contact = collision.contacts[0]; newHandleObjects.AddRange(CutMesh(collision.gameObject, contact.point, transform.right, collision.gameObject.GetComponent <Renderer>().material, true)); for (int i = 0; i < newHandleObjects.Count; ++i) { newHandleObjects[i].gameObject.tag = "Untagged"; newHandleObjects[i].transform.parent = originalHandleParent.transform.root; Destroy(newHandleObjects[i].GetComponent <MeshCollider>()); newHandleObjects[i].AddComponent <BoxCollider>(); } RaycastHit hit; Physics.Raycast(originalHandleParent.transform.position, Vector3.down, out hit); UpperPart = hit.collider.gameObject.name; if (UpperPart == newHandleObjects[0].name) { newHandleObjects[0].transform.parent = originalHandleParent.transform; } else { newHandleObjects[0].layer = LayerMask.NameToLayer("Default"); newHandleObjects[0].AddComponent <Rigidbody>(); grabHandle.GetComponent <ConfigurableJoint>().connectedBody = newHandleObjects[0].GetComponent <Rigidbody>(); grabHandle.transform.parent = newHandleObjects[0].transform; grabHandle.AddComponent <Ball>(); Destroy(newHandleObjects[0].GetComponent <ConfigurableJoint>()); } if (UpperPart == newHandleObjects[1].name) { newHandleObjects[1].transform.parent = originalHandleParent.transform; } else { newHandleObjects[1].layer = LayerMask.NameToLayer("Default"); newHandleObjects[1].AddComponent <Rigidbody>(); grabHandle.GetComponent <ConfigurableJoint>().connectedBody = newHandleObjects[1].GetComponent <Rigidbody>(); grabHandle.transform.parent = newHandleObjects[1].transform; grabHandle.AddComponent <Ball>(); Destroy(newHandleObjects[1].GetComponent <ConfigurableJoint>()); } } } } }
private void Awake() { TeleportAssistActive(false); _controller = this.GetComponent <PlayerViveController>(); }