Hey guys! Im new here, so, sorry if i make the post wrong or this is already answered, but i can’t find the solution anywhere. Well… I’m trying to make a game and i want my player to bleed when he got hit by an enemy, but i don’t want it to bleed every time he got hit. I’d like to put a % of chance to bleed, like it has 30% of chance to bleed if he got hit by the enemy. I have one script working, but it start bleeding if the player lose or reach a certain amount of health. This is my script at the momment:
EDIT**.: I’m editing the script because i made some changes (small changes).
var MaxHealth = 15000;
var Health : int;
var BleedThreshold = 11000;
var bleedTime: float = 5.0; //Time till the player starts to Bleed after timer Trigger
var bleedSpeed = 100; //How fast the Player Bleeds
function Start ()
{
Health = MaxHealth;
}
function Update ()
{
if(Health <= 0)
{
Dead();
}
}
function ApplyDammage (TheDammage : int)
{
Health -= TheDammage;
}
InvokeRepeating("bleeding", 3, 10);
function bleeding ()
{
if(Health <= BleedThreshold && Health > -1)
{
Health -= bleedSpeed;
}
}
function Dead()
{
RespawnMenuV2.playerIsDead = true;
Debug.Log("Your Player Died");
}
function RespawnStats ()
{
Health = MaxHealth;
}
I don’t know if i’m right, because i’m new to this, but, i think i need to make another function just for the bleeding action, out of the update function, in order to make it stop in the future, like, if my player use a painkiller item or something like that, it will stop bleeding. Well, i hope you guys can understand and help me. =D Thanks