Checking Player Health and Dieing! C#

Hi Guys,

I already have a character state called dead which if dead = true then it turns to a ragdoll etc.

What I want is to adjust this slightly, by saying if character is dead, then the health is also 0;

My PlayerHealth Script and the State Class which determines the character states are seperate scripts…

Within TP_Controller; C#

void DetermineCurrentState()
	{
		if (State == CharacterState.Dead)
			PlayerHealth.CurrentHealth = 0;
		
			return;

Within PlayerHealth C#

public class PlayerHealth : MonoBehaviour {

public int MaximumHealth = 100;
public int CurrentHealth = 100;
public float HealthBarLength;

I’ve tried getting a component etc but i’m new to scripting and keep getting lost!

Solved myself.

Cheers :slight_smile: