public void Initialize() { _init = true; _health = GetComponent <Health>(); if (_health != null) { _health.SetCharacter(this); _health.Revive(); } _condition = ConditionState.Normal; _abilities = GetComponents <CharacterAbility>(); _brain = GetComponent <AIBrain>(); foreach (var ability in _abilities) { if (ability.IsPermitted && ability.isActiveAndEnabled) { ability.Initialize(); } } if (_brain != null) { _brain.Activate(); } }
// Respawn the player when it's dead at param point public void RespawnAt(Vector3 respawnPosition) { if (!_init) { Initialize(); } transform.position = respawnPosition; if (CharacterType == CharacterType.NPC) { if (_brain != null) { _brain.ResetBrain(); } } // Reset health on respawn if (_health != null) { _health.Revive(); } }