I am trying to make a simple bullet script that will spawn in a bullet(the bullet itself will have the script that does damage), but I am getting an error.
using UnityEngine;
using System.Collections;
public class shooting : MonoBehaviour {
public float bulletSpeed = 10;
void Fire()
{
Rigidbody bulletClone = (Rigidbody) Instantiate(bullet, transform.position, transform.rotation);
bulletClone.velocity = transform.forward * bulletSpeed;
// You can also acccess other components / scripts of the clone
//rocketClone.GetComponent<MyRocketScript>().DoSomething();
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("Fire1"))
Fire();
}
}
it is telling be that bullet does not exist in this context; there is a bullet in my prefabs, so I am not really sure what is going on.