This shouldn't be in _process()
- that runs every frame so you're potentially making millions of bullets and offsetting them from robotarm by a fixed distance.
Unless, that is, 'can_shoot' turns false when the bullet spawns but there's no can_shoot = false
within this branch. Anyway, that's not a great way of doing it tbh. It's an unnecessary evaluation every frame at the very least. And you're even preloading the scene repeatedly, just make that a member variable (at the top) and do it once.
Change func _process
to func spawn_bullet():
and only call it once when you need a bullet. Then add a _process
in the bullet to handle the movement.
Of course, it could be the material or the parent but I'd tidy up the code first. Hope that helps.