Alternative way to "die"

Hello!

I used an alternative way for the player to “die” and I would like to know if there are any flaws to it, because it seems much simpler then the one provided in the class:

void Update()
    {
        
        Run();
        FlipSprite();
        ClimbLadder();
        Die();
    }

void Die()

    {

         if(myCapsuleCollider2D.IsTouchingLayers(LayerMask.GetMask("Enemies")))

        {

            isAlive = false;

        }

        if(!isAlive)

        {

            runSpeed = 0f;

            jumpSpeed = 0f;

            climbSpeed = 0f;

        }

    }

Hi,

Good job on developing your own solution! :slight_smile:

Did you test it? Does it work? If so, it’s a solution. Nobody knowns if there will be any disadvantages down the road. We are no clairvoyants. For this reason, keep your solution. And if you encounter any issue, solve it. It’s called game development after all, not “write perfect code at the first onset”.

Keep it up!


See also:

2 Likes

Thank you for the reply!

I’ll keep at it!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms