var shield : GameObject;
function Update ()
{
if(Input.GetButtonDown(“Jump”))
{
Instantiate( shield, transform.position, transform.rotation);
GameObject.Find(“shield locator(Clone)”).transform.parent = transform;
}
}
;;;;;;;;
the question i have it every time i click it creates a new one but i only want one active and im stumped. What should i do?
so what it is doing is creating a shield that is parented to my object and follows it. When i click again it creates a new one and the last one stops following. I only want one out. How would i approach that.
Solved
Here is your code:
var shield : GameObject;
function Update ()
{
if(Input.GetButtonDown("Jump"))
{
if(GameObject.Find("shield locator(Clone)") == false)
{
Instantiate( shield, transform.position, transform.rotation);
GameObject.Find("shield locator(Clone)").transform.parent = transform;
}
}
}