hi im having trouble
i want to make a functon update that says:
if guiTexture.pixcelInset.width < 0 : dead = true
its for my healthbar
but every way i have tried hasn’t worked and i haven’t found much googling it
can anybody help?
hi im having trouble
i want to make a functon update that says:
if guiTexture.pixcelInset.width < 0 : dead = true
its for my healthbar
but every way i have tried hasn’t worked and i haven’t found much googling it
can anybody help?
try
if(guiTexture.pixelInset.width <= 0)
dead = true
ive come up with a solution thanks to the pointers. i had to create a variable int called Health and make it the same number as the pixelInset width. then i had to add Health -=“number of health taken off” to my on trigger function
heres the scripts:
//healthbar to go on guiTexture
var Health : int =269;
function Update ()
{
if(Interaction.gotHit)
guiTexture.pixelInset.width -=30;
print(Health);
if(Interaction.gotHit)
Health -= 30;
if(Health<=0)
Interaction.dead = true;
}
function LateUpdate()
{
Interaction.gotHit = false;
if(Interaction.dead)
{
Application.LoadLevel(0);
dead = false;
}
}
// interaction script to go on player
var bullitPrefab :Transform;
static var dead = false;
static var gotHit = false;
function OnTriggerEnter(hit : Collider)
{
if(hit.gameObject.tag == “enemyFire”)
{
gotHit = true;
}
}
//player 1 shoot
function Update()
{
if(Input.GetButtonDown("Fire1"))
{
var bullit =Instantiate(bullitPrefab,
GameObject.Find("Main Camera").transform.position,
transform.rotation);
bullit.rigidbody.AddForce(transform.forward * 4000);
}
var Score = cam_score.score;
if(Score >= 650)
{
Application.LoadLevel(2);
}
}