Hi.
2d game. the character in this script to count the strokes from 10 to 0. In this script I posted a (var myObject: GameObject;) that it will be deactivated as soon as the count reaches 0 shots, but this is not working.
The count when 0 marks the object is not deactivated.
Any solution?
thanks
#pragma strict
var Prefab : Rigidbody2D;
var colpo1 : float = 60;
var dirX = Vector3.right;
var myObject : GameObject;
function Update ()
{
if(Input.GetButtonDown("Fire1"))
{
myObject.SetActive(true);
if(Collisions.GRENADE_AMMO > 0) && myObject.SetActive false;
if(!Prefab || !colpo1)
{
}
else
{
var PrefabCreate: Rigidbody2D = Instantiate(Prefab,GameObject.Find("Projectile Spawn").transform.position, Quaternion.identity);
PrefabCreate.rigidbody2D.velocity = colpo1 * dirX;
Collisions.GRENADE_AMMO --;
GameObject.Find("g_Count").guiText.text = ""+Collisions.GRENADE_AMMO;
print("YOU NOW HAVE " + Collisions.GRENADE_AMMO + "GRENADES");
}
}
}