Hey guys, so my project is a pew pew schmup and while i'm getting by i ran across a problem i'm not sure how to solve:
I have a scene for the player's bullet which has the object, sprite and behavior of a bullet. I instance that scene trough code in my player scene when the [fire] key is pressed and add it as a child of an Area2d node that's my muzzle and where the bullet shoots from.
Now that's all fine and dandy but the bullet, after spawning continues to move relative to the parent(the muzzle node which is a child of the player kinemacticbody2d node), so while it goes up into the screen it also moves left and right with the ship.
Anyway here's the code in the ship node that deals with the shooting:
func Shoot():
if (shotrate <= 0):
var shot = shotscene.instance()
get_node("muzzle").add_child(shot)
print("fire")
shotrate = shotratedef
I'm not sure on how to fix it so the bullet keeps going up but doesnt follow the ship under it, if i don't make it a child it doesn't appear, if i remove the child from muzzle after it spawns it disappears.
And if it's needed too here's the code for the bullet:
func _fixed_process(delta):
move( Vector2(0, speed))
Any help's appreciated, thanks in advance.