/// <summary> /// Kill the player. /// </summary> public void Die() { Instantiate( player.EffectsSettings.DeathEffect, player.Physics.Position, Quaternion.identity ); playerSprite.enabled = false; TransitionManager.Wipe(); player.Physics.Disable(); if (player.CarriedItem != null) { player.CarriedItem.OnPutDown(); } player.EndInteraction(); player.DisableCrouch(this); player.DisableJump(this); player.DisableMove(this); isDead = true; }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player")) { player = other.GetComponent <PlayerCharacter>(); player.DisableMove(this); } }
//------------------------------------------------------------------------- // Unity API //------------------------------------------------------------------------- private void OnEnable() { BoxCollider2D col = GetComponent <BoxCollider2D>(); Collider2D[] hits = Physics2D.OverlapBoxAll(col.bounds.center, col.bounds.size, 0); foreach (var hit in hits) { if (hit.CompareTag("Player")) { player = hit.GetComponent <PlayerCharacter>(); player.DisableMove(this); } } }