When the player is pressing ui_left
, your script is setting the position.x of your Position2D-node to 1 instead of inverting the value. It needs to be:
if sign($Position2D.position.x) == 1:
$Position2D.position.x *= -1
Furthermore a bullet is always freed when _on_Bullet_body_entered
is called, even if the entering body is not an enemy. So this is what happens: You walk around and your code fucks up the muzzle-position, the muzzle is now on top of the player. And the player is a body, too! So if you now spawn a bullet, the body_entered
-signal will be fired and the bullet is getting freed immediately before you can see it.
On an unrelated note: the whole friction-part of your player-script is almost certainly not working as you imagine it to work! By first resetting motion.x
to zero, all linear interpolation afterwards is meaningless (as the current value and goal are already the same, nothing to interpolate anymore). But if you wouldn't do that, you'd interpolate two times each frame when the player doesn't provide any inputs.
Everything was fine until I deleted on of my scenes intentionally and the next time I started Godot It gave an error that dependencies not found and due to that I had to again make my Stage 1.
ALWAYS backup your work - no software is perfect! It may take a while to get used to version control software like git, but I guarantee you it's worth it!
That being said, an error about missing dependencies after you deleted something sounds a lot like you accidentally deleted something that was required somewhere else as well. If that's not the case, it's usually easy to fix manually.