Hi. Does anyone know to stop player from moving and shooting?
Here's my script for my health bar:
var curHealth = 300;
var healthTexture : Texture2D;
var explode:Transform;
var canMove = true;
function Start ()
{
animation["MyCharacterRig|Die"].wrapMode = WrapMode.Once;
animation["MyCharacterRig|Die"].layer = 1;
}
function Update ()
{
if (curHealth <=0 )
{
animation.CrossFade("MyCharacterRig|Die");
}
}
function OnTriggerEnter( hit : Collider )
{
if(hit.gameObject.tag == "enemyProjectile")
{
animation.Play("MyCharacterRig|Hit");
Instantiate(explode, transform.position, transform.rotation);
}
if(hit.gameObject.tag == "enemyProjectile")
{
curHealth -= 15;
}
if(curHealth < 0)
{
curHealth = 0;
}
if (curHealth <= 0)
{
yield WaitForSeconds(1.3);
Application.LoadLevel(2);
}
}
function OnGUI() {
GUI.DrawTexture(Rect(10,10,curHealth,30), healthTexture);
}
i did make it looked like he's dead but when the dead animation is playing i can still move and shoot .
↧