Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | theMX89 |
hi, once again im trying to shoot, i instance the bullet scene ive made at my muzzle, but this shows me following error:
attempt to call function “add_child” in base “null instance” on a null instance.
my script:
func _physics_process(delta: float) -> void:
if Input.is_action_just_pressed("mouseclick"):
var b = bullet.instance()
muzzle.add_child(b) <------- error
b.look_at(raicast.get_collision_point(), Vector3.UP)
pass
i think that if you read the error carefully you can understand where the issue might come from
Andrea | 2021-08-29 12:48
i probably could, but i have no clue what a null instance is and what i should change xD
theMX89 | 2021-08-29 16:09
A null instance is literally nothing, it is an empty object.
The debugger is telling that you are trying to call the method add_child
, from an an empty object.
Since in your code you wrote muzzle.add_child()
, it means that muzzle is empty (=null)
Either you forgot to assign a node to it, or the assignment failed
Andrea | 2021-08-29 17:04
So I have to assign a childnode to it? If not, the muzzle ist a spatial and the bullet is a rigidbody
theMX89 | 2021-08-29 18:35
Im kind of new to godot
theMX89 | 2021-08-29 18:36