No matter what I try, it won’t shoot properly, I’ve tried the tornadoTwins tutorial but I just get errors. I’ve been working on this for about 3-4 hours and I just can’t get it. I’ve tried making the Projectile object itself shoot forward, but then, it always goes along World X. and I’ve tried doing so in the turret script, but then the projectile just falls to the ground -.- . heres my script for the turret. (I’d continue troubleshooting myself, but I’m fairly new to scripting (Took a C++ class in HS but thats about it). besides I have set myself a schedule and do not wish to get behind.)
=============================================
var LookAtTarget : Transform;
var damp = 5.0;
var fireBall : 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);
//transform.LookAt(LookAtTarget);
var seconds : int = Time.time;
var oddeven = (seconds % 2);
if(oddeven)
{
Shoot(seconds);
}
}
}
function Shoot(seconds)
{
if(seconds!=savedTime)
{
Instantiate(fireBall ,transform.Find("spawnPoint2").transform.position ,Quaternion.identity);
fireBall.rigidbody.AddForce(transform.forward * 1000);
savedTime=seconds;
}
}