I am working on what should be a simple instantiate script for firing a projectile.
I have used this syntax before without issue but I cannot get this to run properly. I keep getting an invalid cast exception but as far as I can tell I am keeping the type as a rigidbody.
It is the same code used in the FPS tutorial. I know certain parts are out-of-date but I thought this was still valid.
At this point the script creates instances but they have no velocity.
private var fireDist = 15;
var projectile : Rigidbody;
var fireRate = 0.5;
private var nextFire = 0.0;
function Update () {
var jeepGO = GameObject.FindWithTag("jeep");
var jeep = jeepGO.transform;
var dist = Vector3.Distance(jeep.position, transform.position);
if (dist < fireDist Time.time > nextFire) {
nextFire = Time.time + fireRate;
var bullet : Rigidbody = Instantiate (projectile, transform.position, transform.rotation);
bullet.velocity = transform.TransformDirection (Vector3.up * 100);
}
}
Any help is greatly appreciated,
Kevin