Issue with bullets retaining rotation of gun muzzle.

Godot Version

4.6

Question

So I’m working on a Top-Down Shooter at the moment. I’m making some fairly good progress beginner but this one issue has me stumped! With my shooter, I have a Marker2D on the barrel of my gun which spawns a child bullet that shoots straight out. One of my bullets works perfectly, instantiating right at the barrel and traveling forward without issue. Other bullets however seem to follow the Marker2D in position and rotation past instantiation. My bullets are all in the same class, and the bullet having issues inherits from the basic working bullet.

A gif highlighting my issue in game:

ezgif.com-video-to-gif-converter

The script for the gun I have-

extends Area2D
class_name gun

#Amount of bullets chambered in gun.
var bullets_chambered = 0
#Bullet type currently loaded
var current_bullet = bullet

@export var max_bullets = 5
var can_shoot = true
var can_reload = true

#Timers
@onready var ShotDelay_Timer = $Timers/ShotDelay
@onready var ReloadDelay_Timer =  $Timers/ReloadDelay
@export var shot_waitTime : float = .5
@export var reload_waitTime : float = .5

#region : Bullet List and selected loadout

#Fill out bullet references here.
@export var bullet_loadout = [bullet, bullet, bullet, bullet, bullet, bullet]

#endregion : Bullet List

@onready var GunShot_Sound = $GunShot
@onready var GunDryFire_Sound = $DryFire
@onready var GunReload_Sound = $Reload

func _physics_process(delta):
	var mouse_pos = get_global_mouse_position()
	look_at(mouse_pos)
	
	if Input.is_action_just_pressed("reload"):
		reload_random()
	elif Input.is_action_just_pressed("shoot") and can_shoot:
		shoot()	


func shoot():
	#If bullets in gun are more than 0.
	if bullets_chambered > 0 and can_shoot:	
		
		#Adjust bullet count after shot.
		bullets_chambered -= 1
		print("Chamber: #" + str(bullets_chambered))
		
		#Create bullet instance, with position and rotation at gun barrel. 
		var new_bullet = bullet_loadout[bullets_chambered].instantiate()
		%ShootingPoint.add_child(new_bullet)
		new_bullet.global_position = %ShootingPoint.global_position
		new_bullet.global_rotation = %ShootingPoint.global_rotation
		
				
		#Shoot timer set.
		can_shoot = false
		ShotDelay_Timer.wait_time = shot_waitTime
		ShotDelay_Timer.start()
		
		#Audio Shot.
		GunShot_Sound.playing = true
				
	elif bullets_chambered == 0 and can_shoot:
		
		GunDryFire_Sound.playing = true
		print("Chamber: #" + str(bullets_chambered))
		#Shoot timer set.
		can_shoot = false
		ShotDelay_Timer.wait_time = shot_waitTime
		ShotDelay_Timer.start()
		
func reload_random():
	if bullets_chambered <= max_bullets and can_reload:
			GunReload_Sound.playing = true
			#chambers being added.
			bullets_chambered +=1
			print("reloading...")
			can_reload = false
			ReloadDelay_Timer.wait_time = reload_waitTime
			ReloadDelay_Timer.start()

	
func _on_shot_delay_timeout() -> void:
	can_shoot = true


func _on_reload_delay_timeout() -> void:
	can_reload = true

And the script I have for my bullets-

extends Area2D
class_name bullet

var travelled_distance = 0

@export var bullet_name : String
@export var bullet_speed := 1000
@export var hurt_box := CollisionShape2D
@export var bullet_sprite := AnimatedSprite2D
@export var damage := 1

func _physics_process(delta: float) -> void:
	const range := 1200
	
	var direction = Vector2.RIGHT.rotated(rotation)
	position += direction * bullet_speed * delta
	
	travelled_distance += bullet_speed * delta
	if travelled_distance > range:
		queue_free()


func _on_body_entered(body: Node2D) -> void:
	queue_free()
	if body.has_method("take_damage"):
		
		body.take_damage(damage)

If there’s anymore information I can give that might help let me know! I’ve only recently started diving deeper into GDscript and am really interested in learning more! Thank you!

%ShootingPoint.add_child(new_bullet)

The line above should be replaced.

Right now you use the shooting point as the parent. That means that the children will inherit its transform. Whenever you rotate or move the shooting point, it will affect the bullets too.

Add a new node as a direct child to the root node. Call it “bullets” or something. Then parent tge bullets to it instead of to shooting point.

As @baba said, and then don’t forget to set the bullet’s initial global_position and global_rotation from the Marker2D.