GameSession.cs Overides Death Anim. and such

Hi All,

Just pointing out what I believe to be an unintentional result to implementing the GameSession.cs in the way that we have;

It overides the following method in PlayerMovement.cs:

void Die()
    {
        if (myBodyCollider.IsTouchingLayers(LayerMask.GetMask("Enemies", "Hazards")))
        {
            isAlive = false;
            myAnimator.SetTrigger("Dying");
            myRigidbody.velocity = deathKick;
            FindObjectOfType<GameSession>().ProcessPlayerDeath();
        }
    }

That obviously pushes to GameSession.cs:

public void ProcessPlayerDeath(){
    if (playerLives > 1){
        TakeLife();
    }
    else{
        ResetGameSession();
    }
   }

Which then calls to ResetGameSession:

  void ResetGameSession()
    {
        FindObjectOfType<ScenePersist>().PersistanceIsFutile();
        SceneManager.LoadScene(0); // Could update as checkpoint?
        Destroy(gameObject);
    }

All of this happens and results in the scene being reloaded prior to the deathKick playing out (it can be seen in a few of Rick’s shots throughout the last few sessions of the course section).

I understand how to fix it, but just thought I’d bring it up, so that in case someone else encounters it, you haven’t done anything wrong.

Best,

Paul

2 Likes

Privacy & Terms