- Home /
Inconsistent position setting on scene switch
Hi! I'm currently getting inconsistent results when attempting to define my FPS position/rotation after a scene switch. Specifcially, the 'position' of the FPSController is sometimes correct, but sometimes is remains at its default location. Whether or not I get the correct result seems entirely random (I'll switch back and forth between the same two scenes and get diferent results each time). The rotation setting is always applied correctly, though. This is the code I'm using:
spawnPointName = PlayerDataControl.control.FPSControllerNextSpawnPointName;
spawnLocation = GameObject.Find(spawnPointName).GetComponent().position;
FPSController.transform.SetPositionAndRotation(spawnLocation,PlayerDataControl.control.FPSControllerNextRotation);
'PlayerDataControl' holds stored rotation and the name of the target spawn point GameObject, both of which are persisted from the previous scene.
So, why is this proving to be eratic when setting the position? Could the Find() be causing sync issues? I'm finding this to be very frustrating right now!
Regards,
Guy
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Using a second camera and finding it using a tag 1 Answer
Renderer on object disabled after level reload 1 Answer
Android 2D game how to create swipe left/right views 2 Answers