+1 vote

Hey everybody, I'm trying to spawn a bullet upon clicking the mouse. The problem is the bullet is spawned once and after that the engine doesnt instantiate more with the error "Can't add chil, already has parent".

Here is the code that instantiates the bullet scene:enter image description here

and here is the scene it is being called to: Right Gun is whats callid the shooting script

What am i doing wrong, I've followed the simple shooter sample project?

asked Jan 24, 2017 in Engine by Eldirish (32 points)
edited Jan 24, 2017 by Eldirish

1 Answer

+1 vote
Best answer

[FIXED] Had to use instance the in add_child() so the code became:

var bullet = preload("blal")

func shoot():
 get_tree().get_root().add_child(bullet.instance())
answered Jan 24, 2017 by Eldirish (32 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.