This is the script:
var projectile : Rigidbody;
var speed = 20;
function Update () {
if ( Input.GetButton (“Fire1”)) {
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection( Vector3 (0, 0, speed));
Destroy (clone.gameObject, 3);
}}
Next time please tell us where the error is…
Your problem is in this line :
clone = Instantiate(projectile, transform.position, transform.rotation); clone.velocity = transform.TransformDirection( Vector3 (0, 0, speed));
you have to put a var before clone:
var clone = Instantiate(projectile, transform.position, transform.rotation); clone.velocity = transform.TransformDirection( Vector3 (0, 0, speed));
Don’t forget to mark it as closed.