Projectiles are spawning to the side of markers

Hey y’all, throwing a little project together in Godot 4.1 to practice stuff I learned after a tutorial project. I’ve set up two markers as my projectile spawn points, but the shots are spawning slightly off from the markers and I can’t figure out why. Code and pics below. I “fixed” it by shifting the player sprite2D 5 pixels to the right. Not sure why the spawns are being offset though. NVM that only fixed it at the starting position, the shots are way off when rotating. In editor you can see the markers at the two tips on the ship.

In game you can see the shots spawning just to the side of the markers.

Edit: I broke the formatting posting on mobile 🙃

This snippet is from the player script

` var player_direction = (Globals.player_pos - $FixedHardpointDirection.position).normalized()


<span style="color:#323232;">if Input.is_action_just_pressed("fire_primary") and can_shoot and Globals.laser_ammo > 0 and hardpoint_type == 0:
</span><span style="color:#323232;">
</span><span style="color:#323232;">	Globals.laser_ammo -= 1
</span><span style="color:#323232;">
</span><span style="color:#323232;">	var hardpoint_positions = $ShotStartPositions.get_children()
</span><span style="color:#323232;">
</span><span style="color:#323232;">	can_shoot = false
</span><span style="color:#323232;">
</span><span style="color:#323232;">	$Timers/LaserTimer.start()
</span><span style="color:#323232;">
</span><span style="color:#323232;">	for i in hardpoint_positions:
</span><span style="color:#323232;">
</span><span style="color:#323232;">		player_shot_fixed_weapon.emit(i.global_position, player_direction)
</span>

`

And this is from the level script

` func _shoot_fixed_weapon(pos, direction):


<span style="color:#323232;">var laser = laser_scene.instantiate() as Area2D
</span><span style="color:#323232;">
</span><span style="color:#323232;">laser.position = pos
</span><span style="color:#323232;">
</span><span style="color:#323232;">laser.rotation_degrees = rad_to_deg(Globals.player_rotation)
</span><span style="color:#323232;">
</span><span style="color:#323232;">direction.x = cos(Globals.player_rotation)
</span><span style="color:#323232;">
</span><span style="color:#323232;">direction.y = sin(Globals.player_rotation)
</span><span style="color:#323232;">
</span><span style="color:#323232;">Globals.fixed_hardpoint_direction = Vector2(direction.x,direction.y)
</span><span style="color:#323232;">
</span><span style="color:#323232;">print(Globals.fixed_hardpoint_direction)
</span><span style="color:#323232;">
</span><span style="color:#323232;">laser.direction = Globals.fixed_hardpoint_direction.rotated(-1.5708)
</span><span style="color:#323232;">
</span><span style="color:#323232;">$Projectiles.add_child(laser)
</span>

`

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • test
  • CafeMeta
  • [email protected]
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • TheResearchGuardian
  • Ask_kbincafe
  • KbinCafe
  • feritale
  • Socialism
  • oklahoma
  • SuperSentai
  • KamenRider
  • All magazines