Godot Version
4.5 stable
Question
So, I’m making a 2D physics platformer and using CharacterBody2D for my characters. When the end of a stage is reached, I want to instantly create a new stage and set the player characters to some new starting position. When a new stage is created, the tiles are procedurally/randomly placed. Within that procedural placement, I have a signal that emits the actual x and y coordinates of each tile placed:
The root node of the stage scene uses this signal to tell the player spawner node where to place the player characters. (Basically, all that you need to know here is that we’re deciding the x and y to place the players at):
(I was originally using an array of the ground tiles after they were generated to calculate the x and y for each player, but that wasn’t working either, so I’m just trying a signal instead. I might prefer the direct calculation method. But I digress)
Here is everything that is happening in that place_player function:
The spawn_offset is just negative half the height of the player so that they don’t spawn inside the ground. It’s not relevant to the issue (I’ve tested).
The issue is that the players appear to spawn on the previous stage’s ground coordinates, not the new one’s, whenever a new stage is created. For example, when the ground is lower on a new stage, they spawn a bit above it.
Which is very odd, because I print out the coordinates they are placed at, and they do not match up. See the print call above. It prints the position, then places a player there. The printed position is correct, where it should be. However, the players are not placed there. Please observe this effect in this video:
A quick explanation/summary of the video just in case:
The players are placed at y position 368 (seen in the output at the bottom left).
I drag a character to the end of the stage, whereupon a new stage is created and the players are given new positions.
The new y position is supposed to be 400, as printed in the output.
Instead, the players appear to have been placed above that, at 368, before falling down.
Edit: Also, it looks like one of them even appears in a weirder spot… just noticed that and don’t know why that is, either.
Why might something like this happen?



