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)
↧