hi, i’m new to Unity and trying to learn some scripting.
i want to make a FPS shooter and watched some tutorials but i stil dont know how to fix his problem. when i want to shoot an error appears: The variable bullet of ‘Shooter’ has not been assigned. does someone know how to fix this?
using UnityEngine;
using System.Collections;
public class Shooter : MonoBehaviour {
public GameObject bullet = null;
public float bulletspeed = 500;
private void Update () {
if (Input.GetKeyDown(KeyCode.F))
{
GameObject shot = GameObject.Instantiate(bullet, transform.position + (transform.forward * 2), transform.rotation) as GameObject;
shot.rigidbody.AddForce(transform.forward * bulletspeed);
}
}
}