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.
Edit: I broke the formatting posting on mobile 🙃
This snippet is from the player script
` var player_direction = (Globals.player_pos - $FixedHardpointDirection.position).normalized()
if Input.is_action_just_pressed("fire_primary") and can_shoot and Globals.laser_ammo > 0 and hardpoint_type == 0:
Globals.laser_ammo -= 1
var hardpoint_positions = $ShotStartPositions.get_children()
can_shoot = false
$Timers/LaserTimer.start()
for i in hardpoint_positions:
player_shot_fixed_weapon.emit(i.global_position, player_direction)
`
And this is from the level script
` func _shoot_fixed_weapon(pos, direction):
var laser = laser_scene.instantiate() as Area2D
laser.position = pos
laser.rotation_degrees = rad_to_deg(Globals.player_rotation)
direction.x = cos(Globals.player_rotation)
direction.y = sin(Globals.player_rotation)
Globals.fixed_hardpoint_direction = Vector2(direction.x,direction.y)
print(Globals.fixed_hardpoint_direction)
laser.direction = Globals.fixed_hardpoint_direction.rotated(-1.5708)
$Projectiles.add_child(laser)
`