I set up a system where when the player enters a door, it changes the player’s position. However, when I walk through the door, it doesn’t take me where I want it to. On top of that, it tells the player’s position is exactly where I want it, but it’s outside the map. I’ve included a video to demonstrate. How can I fix this?
It worked: changing the position through the remote tab took me to the correct location. So with this in mind, how can I achieve this through a script? (gdscript)
need to see your script how do you move the player from the “kitchen” to “little room”, might there be something not adding to the end value position you wanted
try changing the .position to .global_position instead
also instead of typing exactly which position it spawns, use Marker2D to set position of spawn, get that Marker2D node global_position and use it to move the playerNode’s global_position to it
i expect it didnt work, because the Vector2() position should not reflect where it spawn as global position, because the inspector’s position only show the position, not global position
my suggestion is to make it clear and always correct by using a Marker2D or really just a Node2D as a child of the rooms for your spawn global position point reference
The cleantable room is a node right?, you can try to remove the current teleport player code and do something like player.global_position = $CleanTable.global_position
All the rooms are just Sprites with CollisionShape2D’s on top of them. So far, I’ve tried Marker2D and putting the Sprites inside a Node2D and they both have a similar thing, where with global_position, the Node sets it to 0,0 since that’s where it is in the node, but when setting the global_position for the player, it sends it to the entire scene’s 0,0 coordinates instead.
i think you did it not right, you put the node2d/marker2d node in a position in the editor, then in script, you just need to get the global_position of it by spawnposition.global_position and put it in playerNode.global_position
Tries to achieve something similar with this script by having one Area2D moved around via positions instead of having a ton of Area2D’s, though this in particular does not effect the player position.