- Edited
Sorry this question may be a bit long.
I'm working on my first game, and for some reason, changing the player's position doesn't seem to take effect immediately.
When the player walks on a bridge, my script disables the player's mask 1, so the player will not collide with the edge of the ground. When the player goes from the wooden bridge to the stone bridge, the log shows the player "exited" the wooden bridge and "entered" the stone bridge, which are all as expected.
Now the player goes back to the save list, the player "exited" the stone bridge because my script removes the map and loads the UI scene, which is also reasonable.
Now if the player resumes the save, some strange things happen. The player "entered" both stone bridge and wooden bridge, then "exited" stone bridge. Because my script enables player's mask 1 when the player leaves the bridge (no matter which bridge), the player collides with the edge of the ground and can not walk out of the bridge now.
I checked my code and the process is:
When the player resumes the save, I change the player's position first and then loads the map, but the log shows the player still collides with two bridges ,which is weird.
Currently I solve this problem by moving the player to a really far place when removing the map, but I'm still curious about why the player can collide with two bridges at the same time.