im not sure what the problem is all i want is for it to spawn the gameobject and add velocity to it but i keep getting this error
here is the code
using UnityEngine;
using System.Collections;
public class Fire_script : MonoBehaviour
{
public GameObject bullet; // Prefab of the bullet.
public float speed = 20f; // The speed the bullet will fire at.
private follow_crosshairs playerCtrl; // Reference to the PlayerControl script.
void Start()
{
}
void Update ()
{
// If the fire button is pressed...
if(Input.GetButtonDown("Fire1"))
{
{
Getting NullReferenceException: Object reference not set to an instance of an object Fire_script.Update () (at Assets/Fire_script.cs:29)?
// ... instantiate the rocket facing right and set it's velocity to the right.
Rigidbody2D bulletInstance = Instantiate(bullet, transform.position, Quaternion.Euler(new Vector3(0,0,0))) as Rigidbody2D;
bulletInstance.velocity = new Vector2(speed, 0);
}
}
}
}
i do have the bullet working it just doesn’t add velocity it sort of just lands on the ground. please help if you can. C#