heres the script. we want it to shoot one block but its shooting almost a million a sec
we made this script so don't say oh you copyed this script or whatever.
var blockPrefab:Transform;
var Stickyblock:Transform;
function Update ()
{
if(Input.GetButtonDown("Fire1"))
{
var block = Instantiate(blockPrefab, GameObject.Find("Cube").transform.position, Quaternion.identity);
var sticky = Instantiate(Stickyblock, GameObject.Find("Stickyblock").transform.position, Quaternion.identity);
}
}
this question is morphing, but here is the answer to your comment. This will force the user to click each time they want to fire...
var blockPrefab:Transform;
var targetT:Transform;
function Start ()
{
GameObject go = GameObject.Find ("Stickyblock");
// cache the transform component, for performance
targetT = go.transform;
}
function Update ()
{
var canFire = 1;
if(Input.GetButtonDown("Fire1"))
{
if (canFire == 1}
{
var block = Instantiate(blockPrefab, GameObject.Find("Cube").transform.position, Quaternion.identity);
var sticky = Instantiate(Stickyblock, targetT.position, Quaternion.identity);
canFire = 0;
}
else if (Input.GetButtonUp ("Fire1"))
{
canFire = 1;
}
}
Hey man, why are you using find to set the transform position? Not got Unity fired up atm but `Stickyblock, GameObject.Find("Stickyblock")`
looks like it will loop?