BastiaanOlij / godot_background_loading

Example project for my background loading tutorial
MIT License
13 stars 4 forks source link

Fixes issue with player_position by fully resetting player's transform #2

Open zombieCraig opened 4 years ago

zombieCraig commented 4 years ago

The player_position() method only works the first time in the demo. If you load a scene again you will not spawn where you expect. See https://github.com/zombieCraig/godot_background_loading/tree/position_test for a demo of the issue.

I've placed the center menu behind the boxes. And if you move in position to click the button it will attempt to load the same level which should start you in the same place but it won't.

Turns out this was a bug in FADE_TO_BLACK_1 transition state. The $OVRFirstPerson global transform wasn't being reset properly.

BastiaanOlij commented 4 years ago

Hey @zombieCraig ,

That would kinda almost do what you want it to do but I accidentally stumbled into this myself yesterday and the culprit is this line of code: https://github.com/BastiaanOlij/godot_background_loading/blob/master/player/player.gd#L43

It shouldn't be using the cameras global_transform but it should be using the cameras local transform. That would correctly center the player on the location given to this function.