Every assets in the world is misalign

Godot Version

4.6.1

Question

Hello, new user here on godot2d. I need help with placing assets scenes correctly in the level scene. For example, i made a player and checkpoints(green box) scenes and placed them into the level test scene. I had to placed the checkpoint way above the player and platforms in order for the checkpoint to work. If I put the checkpoint on the floor, like how i wanted too and the player passes it and dies off the map, the player wont respawn on the checkpoint. But the player will spawn underneath the platform and will die over and over underneath. Another example, where i created a turret enemy with a raycast2d but the raycast is not properly targeting the player. Im not sure how to fix this issue; it almost seems like it happens with every scene really. Any help is appreciated!

Are you sure the position of the sprite in the respawn and player scenes both are 0.0? Open the scenes up and check if they are at position 0.0.

Use global_position instead of position.

i made sure the player scene, the test level scene, and enemy raycast positions are at 0,0. The problem is still there

i did use global_position in the shooting enemy script. Here’s the full code:

extends CharacterBody2D


const SPEED = 300.0
var direction: Vector2
var fireballNode
@onready var fireball_spawn: RayCast2D = $RayCast2D
@onready var fireball = preload("res://Assets Scenes/fireball.tscn")


func _ready() -> void:
	_shoot()
	
func _physics_process(delta: float) -> void:
		var player = get_tree().get_first_node_in_group("Player_Dragon")
		if player == null:
			return
	
		$RayCast2D.target_position = player.global_position - $RayCast2D.global_position
		fireball_spawn.look_at(player.global_position)
		move_and_slide()
	
func _shoot():
	fireballNode = fireball.instantiate()
	get_parent().add_child.call_deferred(fireballNode)
	fireballNode.global_position = $RayCast2D.global_position
	
	$SpawnTimer.start()
	
func _on_spawn_timer_timeout() -> void:
	_shoot()

Global position should be set after the node has been added to the tree.

Thank you for the tip! Also this code ‘fireball_spawn.look_at(player.global_position)’ and ‘fireballNode.global_position = $RayCast2D.global_position’ was rotating the raycast2d; not to be accurately aim to the player.