#pragma strict
var theBullet : Rigidbody;
var theBullet2 : Rigidbody;
var Speed = 5000;
var shots : int = 200;
var Error : AudioClip;
function Update () {
if(Input.GetAxis(“QFireOrange”))
{
var clone = Instantiate(theBullet, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection(Vector3(0,0,Speed));
Destroy (clone.gameObject, 2);
}if(Input.GetAxis("FFireGreen"))
{
var clone2 = Instantiate(theBullet2, transform.position, transform.rotation);
clone2.velocity = transform.TransformDirection(Vector3(0,0,Speed));
if(theBullet2 == null){
audio.PlayOneShot(Error);
}
Destroy (clone.gameObject, 2);
}
//guiText.text = "Shots Left:" + shots;
}
This is my script . As you can see when I press the QFire or FFire buttons( Q and F) a rigidbody is spawned and sent forwards across the Z axis . But when it spawns it goes forward and then flies up for no apparent reason . How can I fix this .
It also gives me a warning which I don’t understand :
The referenced script on this Behaviour is missing!
UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
PrefabShooting:Update() (at Assets/Tutorial 5/Tutorial 5/PrefabShooting.js:11)
Are these two problems linked ?