I’m trying to create a bullet via the usage of a prefab and then adding force it.
It doesn’t matter how i try to make it work , I keep getting a nullReference error.
The code:
void shoot(){
if (Time.time >= coolDown) {
GameObject bPrefab = Instantiate(bulletPref,this.transform.position,Quaternion.identity) as GameObject;
bPrefab.GetComponent<Rigidbody2D>().AddForce(transform.forward * velocity);
coolDown = Time.time + attackSpeed;
}