Quantcast
Channel: Questions in topic: "dontdestroyonload"
Viewing all articles
Browse latest Browse all 416

Problems with transforming my DontDestroyOnLoad Player to a startingPoint on a new scene

$
0
0
Hello, I have a problem with my script public class PlayerStartingPoint : MonoBehaviour { private PlayerControllerLandscape playerControllerLandscape; private CameraControllerLandscape cameraControllerLandscape; private void Start() { Invoke("SetPlayerToStartPoint", 0.01f); } public void SetPlayerToStartPoint() { print("hi"); playerControllerLandscape = FindObjectOfType(); playerControllerLandscape.transform.position = transform.position; cameraControllerLandscape = FindObjectOfType(); cameraControllerLandscape.transform.position = new Vector3(transform.position.x, transform.position.y, cameraControllerLandscape.transform.position.z); } } This script works but if i just write SetPlayerToStartPoint(); this script won´t "work" (it works the first time but when I load a new Scene(trigger on Exitplate) it just loads my character to the coordinates of the Exitplate in the new Scene, not the Startplate), my PlayerControllerLandscape and my CameraControllerLandscape have both DontDestroyOnLoad in the script. The print("hi"); always works, and I also tried to check if(playerControllerLandscape != null) which is always true. I also tried to load this script last in the ScriptExecutionOrder, which didn´t help. I hope someone can help me. Greetings

Viewing all articles
Browse latest Browse all 416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>