607
submitted 3 months ago by [email protected] to c/[email protected]
you are viewing a single comment's thread
view the rest of the comments
[-] cookie_sabotage 159 points 3 months ago
public class GameManager : MonoBehaviour
{
    public bool EnableHighContrast;
    public bool PlayerWon;
    public float PlayerUnitsMoved;
    public int PlayerDeathCount;
    public float PlayerHealth;

    public void PlayerTakeDamage(float damage)
    {
        PlayerHealth -= damage;
        if (PlayerHealth < 0)
        {
            PlayerDieAndRespawn();
        }
    }

    public void PlayerDieAndRespawn()
    {
        return;
    }
}

I couldn't contain myself.

[-] [email protected] 57 points 3 months ago

Should it be

PlayerHealth <= 0

?

Otherwise the player could have 0 health and not die? I’m sleep deprived so forgive me if I’m wrong

[-] [email protected] 26 points 3 months ago

Open up ticket first, please. Thanks Codemonkey.

load more comments (9 replies)
load more comments (16 replies)
this post was submitted on 28 Mar 2024
607 points (98.1% liked)

Programmer Humor

31331 readers
23 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 4 years ago
MODERATORS