I'm making a 2D platformer. I added ladder to my project.
Area2D -> TileMap ->tileset(ladders.tres). Area2D has a script:
func onArea2Dbodyentered(body):
if body.name == "Player":
getnode("../Player").ladderon = true
func onArea2Dbodyexited(body):
if body.name == "Player":
getnode("../Player").ladderon = false
My hero can jump up the ladder and jump off. But I cannot implement centering the hero along the x-axis on the ladder. How to move the hero to the center of the ladder along the x-axis? There is a scene where I created a tileset (Convert to... TileSet). Node2D -> Sprite -> StaticBody2D -> ColisionShape2D -> Position2D. My idea is, if the ladder sends a signal to the hero and ladder_on == true changes and if at this moment the up button is pressed, then gravity will be canceled and the global position of the hero will take on the x Position2D value of the ladder. Thus, the hero will move to the center of the ladder. But how does the hero get x Position2D ladder? maybe there is another way to move the hero to the center of the ladder?