private void OnTriggerEnter(Collider other) { DeathBarrier deathBarrier = other.gameObject.GetComponent <DeathBarrier>(); if (deathBarrier) { deathBarrier.Kill(gameObject); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.layer == LayerMask.NameToLayer("SmasherJump")) { currentJumpObject = other.gameObject.GetComponentInParent <JumpObject>(); currentJumpInfo = currentJumpObject.GetJumpPositionIndex(groundCheck); currentJumpPoints = currentJumpObject.GetJumpPoints(currentJumpInfo); bEnteredJumpTrigger = true; if (!bJumping) { if (currentState == MonsterState.Chasing) { StartJump(currentJumpPoints, currentJumpInfo, playerTransform.position); } else if (currentState == MonsterState.Patrolling) { if (currentWaypoint) { float point2Distance = Vector3.SqrMagnitude(currentWaypoint.position - currentJumpPoints[1].position); float point1Distance = Vector3.SqrMagnitude(currentWaypoint.position - currentJumpPoints[0].position); //Check if jump would bring us closer to the current waypoint if (point2Distance < point1Distance) { StartJump(currentJumpPoints, currentJumpInfo, currentWaypoint.position); } } } else if (currentState == MonsterState.Investigating) { //Check if jump would bring us closer to the player's last known position float point2Distance = Vector3.SqrMagnitude(lastKnownPlayerPosition - currentJumpPoints[1].position); float point1Distance = Vector3.SqrMagnitude(lastKnownPlayerPosition - currentJumpPoints[0].position); if (point2Distance < point1Distance) { StartJump(currentJumpPoints, currentJumpInfo, lastKnownPlayerPosition); } else { Debug.Log("Jump not worth it"); } } } } DeathBarrier deathBarrier = other.gameObject.GetComponent <DeathBarrier>(); if (deathBarrier) { deathBarrier.Kill(gameObject); } }
void Awake() { _Instance = this; }