private void OnTriggerEnter(Collider other) { InteractibleObject interact = other.GetComponent <InteractibleObject>(); if (interact != null && interact.type != InteractibleObject.InteractType.FusePoint) { interact.Interact(other.transform.position); } }
private void OnTriggerStay(Collider other) { InteractibleObject interact = other.GetComponent <InteractibleObject>(); if (interact != null && ( interact.type == InteractibleObject.InteractType.DangerZone || interact.type == InteractibleObject.InteractType.Death)) { interact.Interact(other.transform.position); } }
private void OnParticleCollision(GameObject col) { if (col.CompareTag("Player")) { MovementController movementController = col.GetComponent <MovementController>(); Rigidbody playerRigidbody = col.GetComponent <Rigidbody>(); if (!movementController.DamageCoolDownActivated) { movementController.DamageCoolDownActivated = true; // damage player InteractibleObject interactibleObject = GetComponent <InteractibleObject>(); if (interactibleObject != null && interactibleObject.type == InteractibleObject.InteractType.Damage) { interactibleObject.Interact(transform.position); } } if (movementController.IsFuseMoving) { return; } // bump player back if (ParticlesOnCollision != null) { Vector3 position = movementController.transform.position; position.y = 0.5f; Instantiate(ParticlesOnCollision, position, Quaternion.identity); AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.HurtPlayer, _audioEvents, gameObject); } if (movementController.IsMoving) { Vector3 targetPos = movementController.transform.position - movementController.transform.forward * movementController.DamageBounceValue; targetPos.y = 0; StartCoroutine(movementController.MoveBackRoutine(targetPos, MovementController.MoveDuration)); } else { _particleSystem.GetCollisionEvents(col, _collisionEvents); Vector3 collisionForce = _collisionEvents[0].velocity; collisionForce.y = 0; playerRigidbody.AddForce(collisionForce * WaterForce); } } }
private void CheckRayCollision(float height, float width) { RaycastHit hit; if (Physics.Raycast(new Vector3(transform.position.x + width, height, transform.position.z), transform.forward, out hit, Vector3.Distance(transform.position, TargetPosition))) { InteractibleObject interactableObj = hit.transform.gameObject.GetComponent <InteractibleObject>(); if (interactableObj == null) { return; } interactableObj.Interact(hit.point); if ((IsDashing && interactableObj.IsBreakable) || interactableObj.type == InteractibleObject.InteractType.BurnableProp) { CheckCollision(); } } }