Hellooooo again
I’m trying to get my player I have moving around to actually shoot, I’ve had a look through the manual pages on instantiation but I’m still struggling to get it to work
using UnityEngine;
using System.Collections;
public class playerShoot : MonoBehaviour
{
// Update is called once per frame
void Update ()
{
Object bullet = GameObject.FindWithTag("bullet");
if(Input.GetButtonDown("Fire1"))
{
GameObject muzzle = GameObject.FindWithTag("Player");
Object clone = Instantiate(bullet, muzzle.transform.position, muzzle.transform.rotation);
}
}
}
I’ve tried replacing the “Object” lines with “GameObject” but I still can’t get it to work, the error message I’m getting is:
NullReferenceException: The prefab you want to instantiate is null.
Could someone please help as I’m still learning this scripting stuff and I’ve been trying all sorts for the last couple of hours and still can’t get a bullet to come out
My bullet prefab has a “bullet” tag on it, and I know the muzzle I’m using at the moment is just the player location as I wanted to just get something working before I juggle things around
Thanks in advance for the help!