public void DamagePlayer(float damageValue) { GameObject LH = GameObject.FindGameObjectWithTag("Left Hand"); GameObject RH = GameObject.FindGameObjectWithTag("Right Hand"); if (LH != null) { leftCont = LH.GetComponent <Left_VR_Cont>(); StartCoroutine(leftCont.PulsedVibration(10, 10, 0.1f, 1)); } if (RH != null) { rightCont = RH.GetComponent <Right_VR_Cont>(); StartCoroutine(rightCont.PulsedVibration(10, 10, 0.1f, 1)); } hurtSound.Play(); currentPlayerHealth -= damageValue; if (currentPlayerHealth <= 0) { currentPlayerHealth = 0; UpdateStatsOnUI(); GameOver(false); } else { UpdateStatsOnUI(); } }
// Use this for initialization void Start() { IPL = Singleton_Service.GetSingleton <Input_Listeners>(); active = true; text.text = "Hellooo!!"; activate(false); right = hand.GetComponent <Right_VR_Cont>(); left = hand.GetComponent <Left_VR_Cont>(); }
//if hit by the plyaer sword, the marker is marked as hit void OnCollisionEnter(Collision other) { if (other.collider.CompareTag("Player Sword") || other.collider.CompareTag("Shuriken")) { Debug.Log("Collided"); leftController = GameObject.FindGameObjectWithTag("Left Hand").GetComponent <Left_VR_Cont>(); rightController = GameObject.FindGameObjectWithTag("Right Hand").GetComponent <Right_VR_Cont>(); rightController.PulseVibrate(10, 10, 0.001f, 1); SetHitStatus(true); if (attachedEnemy != null) { if (!attachedEnemy.HitAlreadySignaled()) { attachedEnemy.SignalAHit(this.gameObject); ContactPoint[] points = other.contacts; foreach (ContactPoint point in points) { if (point.otherCollider.CompareTag("Player Sword") || point.otherCollider.CompareTag("Shuriken")) { attachedEnemy.StartCriticalHit(point.point); } } } } else { ContactPoint[] points = other.contacts; foreach (ContactPoint point in points) { if (point.otherCollider.CompareTag("Player Sword") || point.otherCollider.CompareTag("Shuriken")) { attachedEnemy.StartCriticalHit(point.point); } } } } }