hey guys im following a tutorial series on youtube and im on step 11....which can be found here
I can make the turret shoot but when i push spacebar the turret shoots instead of the worm. I dont understand what i did wrong.
Here is the code:
var LookAtTarget:Transform;
var damp = 6.0;
var bullitPrefab:Transform;
var savedTime=0;
function Update ()
{
if(LookAtTarget)
{
var rotate = Quaternion.LookRotation(LookAtTarget.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp);
var seconds : int = Time.time;
var oddeven = (seconds % 2);
if(oddeven)
{
Shoot(seconds);
}
}
}
function Shoot(seconds)
{
if(seconds !=savedTime)
{
var bullit = Instantiate(bullitPrefab ,transform.Find("spawnPoint").transform.position ,
Quaternion.identity);
bullit.rigidbody.AddForce(transform.forward * 1000);
savedTime=seconds;
}
}
If you cant help i understand. its ok. ill find help on their website hopefully if they ever write back. thanks anyway.