I am super new to Godot and am still trying to learn it using C#. I have a character that runs around and jump. I am trying to make it that whenever the player hits spacebar, their gun shoots. I currently have the bullet scene added as a node of the weapon scene, and the code I use for firing the weapon is:
public void FireWeapon()
if ((Input.IsActionJustPressed("moveShoot")) && (firingDelay < 0))
var newBullet = (StaticBody2D)Bullet.Instance();
However, when I press spacebar, I get the following error:
E 0:00:27.237 void Weapon.FireWeapon(): System.NullReferenceException: Object reference not set to an instance of an object.
<C++ Error> Unhandled exception
<C++ Source> /Users/willbur/Desktop/Personal/Computer Science/Godot Engine/PROJECTS/Comfy Couch/SCENES/WEAPONS/Weapon.cs:56 @ void Weapon.FireWeapon()()
Weapon.cs:56 @ void Weapon.FireWeapon()()
Weapon.cs:37 @ void Weapon._Process(Single )()
As I am new to Godot, I have no idea if I am approaching this correctly, so any and all help is appreciated!