示例#1
0
    /// <summary>
    /// Makes the player respawn at the location passed in parameters
    /// </summary>
    /// <param name="spawnPoint">The location of the respawn.</param>
    public override void RespawnAt(Transform spawnPoint, FacingDirections facingDirection)
    {
//		if (!gameObject.activeInHierarchy)
//		{
//			//Debug.LogError("Spawn : your Character's gameobject is inactive");
//			return;
//		}

        UnFreeze();

        // we make sure the character is facing right
        Face(facingDirection);

        // we raise it from the dead (if it was dead)
        ConditionState.ChangeState(CharacterStates.CharacterConditions.Normal);
        // we re-enable its 2D collider
        this.gameObject.MMGetComponentNoAlloc <Collider2D>().enabled = true;
        // we make it handle collisions again
        _controller.CollisionsOn();
        transform.position = new Vector3(spawnPoint.position.x, spawnPoint.position.y, transform.position.z);
        if (_health != null)
        {
            _health.ResetHealthToMaxHealth();
            _health.Revive();
        }
        respawnFeedback?.PlayFeedbacks();
    }