I am at University in Leeds making a side scroller game for kids. Here is my health script i know it works but i need to make it take off health on a collision with my barrels in my scene. The barrels have a mesh colliders and the character has a character controller attached as well as other scripts for other things. My health bar is updated in the GUI when i test it but i can’t get the collision to work. Also how to regenerate the health once my re spawn script takes him back to the start. Many thanks for having a look at this!
var h00 : Texture2D;
var h25 : Texture2D;
var h50 : Texture2D;
var h75 : Texture2D;
var h100 : Texture2D;
static var HEALTH = 100;
function Update()
{
var g_Health = gameObject.Find(“g_Health”);
if(HEALTH > 75)
{
g_Health.guiTexture.texture = h100;
return;
}
else if (HEALTH > 50)
{
g_Health.guiTexture.texture = h75;
return;
}
else if (HEALTH > 25)
{
g_Health.guiTexture.texture = h50;
return;
}
else if (HEALTH > 10)
{
g_Health.guiTexture.texture = h25;
return;
}
else if (HEALTH <= 0)
{
g_Health.guiTexture.texture = h00;
return;
}
}