I'm making a 2D platformer with ladders. As I begin to build the ladder mechanic i'm running into a few issues.
The Ladder's root node is an Area2D, with a Sprite and CollisionShape2D. The scene is autoloaded to make it accessable to other scripts. The CollisionShape2D is set to 'Make unique' allowing me to scale the ladder's sprite with it's collision shape.
I'm centering the Player on the ladder when he collides with the Ladder.
Getting the reference for the location of the Ladder in the Ladder's script:
var ladder_position = Vector2()
func _ready() -> void:
ladder_position.x = self.global_position.x
In the Player's script I use the position of the Ladder and apply it to the Player:
func _on_Ladder_on_ladder() -> void:
self.global_position.x = Ladder.ladder_position.x
I'll need to move the instanced Ladder's to the relevant location on my level map. But the problem is that the location the Player receives is the one before the Ladder is moved. I don't know how to get the current position of the Ladder.
Currently when the Player collides with the ladder, it is set to the top left corner of the screen (0,0).
What should I do?