I cannot get this code to work for the life of me! So now I come to you the great Unity Community to give me a helping hand! Please show me what I am doing wrong. Thank you!
public var deathBall: Rigidbody;
public var ballSpeed: float = 25.0;
private var reloadTime: float;
private var canShoot: boolean;
function Start()
{
reloadTime = 0.0;
canShoot = true;
}
function Update ()
{
if(canShoot == true)
{
MouseClick();
}
reloadTime += Time.deltaTime;
if(reloadTime >= 2.0)
{
canShoot = true;
reloadTime = 0.0;
}
else if(reloadTime <= 2.0)
{
canShoot = false;
}
}
function MouseClick()
{
if(Input.GetButtonDown("Fire1"))
{
Instantiate();
canShoot = false;
}
}
function Instantiate()
{
var newBall : Rigidbody = Instantiate(deathBall, transform.position, transform.rotation);
newBall.velocity = transform.TransformDirection(Vector3(0, 0, ballSpeed));
Physics.IgnoreCollision(newBall.collider, transform.root.collider);
}