Welcome to the forums @epshteinmatthew!
A few things that could be causing the issue is that you are using local position variables for the bullet's movement, which could be causing it to not move, especially if the bullet's relative transform is small. If you want the bullet to move in the direction of its rotation, instead of using transform.x
, you instead want to convert the rotation to a direction vector. Here's the code I would suggest using for the bullet:
extends Area2D
export (float) var speed = 750
func _physics_process(delta):
global_position += Vector2(cos(rotation), sin(rotation)) * speed * delta
Then the bullet should move as expected! However, you will likely run into another issue, but thankfully it is easy to fix. The issue you may encounter is that the bullets will move when the player moves! This is because they are children nodes to the player, meaning they will inherit any offsets to the player's transform (position, rotation, and scale).
To fix this issue, in the shoot
function, just change self.add_child(b)
to get_parent().add_child(b)
and the bullets will no longer be offset when the player moves.