here is the script :
#pragma strict
var mycar : Transform ;
var boom : Transform ;
var carInRange = false ;
var shotTime : int ;
var reloaded ;
var late : float = 0.2 ;
var entazer = 0 ;
var qowwatDefa3 = 2000 ;
var chkdistX : int ;
var chkdistZ : int ;
function Awake ()
{
reloaded = true;
}
function update ()
{
shotable () ;
if (carInRange)
{
var far2 = Quaternion.LookRotation (mycar.position - transform.position );
transform.rotation = Quaternion.Slerp (transform.rotation , far2 , Time.deltaTime * late);
shotTime = Time.time ;
reloaded = shotTime % 2 ;
if (reloaded)
{
Attackcar (shotTime);
carInRange = false ;
}
}
}
function Attackcar (shotTime)
{
if (mycar)
{ if (carInRange)
{ if (shotTime != entazer)
{ var boom2 = Instantiate (boom, transform.Find ("modfa3").transform.position, Quaternion.identity);
boom.rigidbody.AddForce (transform.forward * qowwatDefa3 ) ;
entazer = shotTime ;
}
}
}
}
function shotable ()
{
var tankPosX = transform.position.x;
var tankPosZ = transform.position.z;
var carPosX = mycar.transform.position.x;
var carPosZ = mycar.transform.position.z;
chkdistX = float = carPosX - tankPosX ;
chkdistZ = float = carPosZ - tankPosZ ;
if ((chkdistZ < 15) && ((chkdistX < 15) && (chkdistX > -15)))
{
carInRange = true;
}
else
{
carInRange = false ;
}
}
plz can any one help me