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

Problem using DontDestroyOnLoad carrying over a player, but not a camera

$
0
0
So, I am trying to make an overhead 2D RPG. The tutorial series I am watching carried over both the Camera and the Player, but I want the camera background to have a different color in this different scene. Now here's my question, is there a way to have the camera follow something that is in the DontDestroyOnLoad category? Or is there some way to have this Camera change background color when it switches to a new scene? DontDestroyOnLoad(transform.gameObject); if (GameObject.Find(gameObject.name) && GameObject.Find(gameObject.name) != this.gameObject) { Destroy(GameObject.Find(gameObject.name)); } (This is the code I use for the Player) { public GameObject followTarget; private Vector3 targetPos; public float moveSpeed; // Use this for initialization void Start () { } // Update is called once per frame void Update () { targetPos = new Vector3(followTarget.transform.position.x, followTarget.transform.position.y, transform.position.z); transform.position = Vector3.Lerp(transform.position, targetPos, moveSpeed * Time.deltaTime); } } (And this is the camera script)

Viewing all articles
Browse latest Browse all 416

Latest Images

Trending Articles



Latest Images

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