- Home /
Camera is not working on Unlockable characters
I have a car object on the scene and everything works including the camera follow script; I have also array of lockable cars(ui button) in a scene called MainScene On another scene I have a game object spawning those cars. Car selection works fine,but when the new character is selected, the camera doesn’t follow the newly unlocked car. I would like to have camera fellow lockable cars. So far I am not seeing the results
Here is the camera follow script
GameObject FindCharacter; Vector3 offset; public bool GameOver; private void Start() { ``// offset = transform.position - target.position;
FindCharacter = GameObject.FindGameObjectWithTag("Player");
offset = new Vector3(6.0f, 3.0f, -6.0f);
GameOver = false;
}
void Update()
{
if (!GameOver)
{
Follow();
}
}
public void Follow()
{
// transform.position = target.position + offset;
transform.position = FindCharacter.transform.position + offset;
}
Here is array of unlockable cars script public class GameManagement : MonoBehaviour { public GameObject[] PlayerList; // Start is called before the first frame update void Start() { GenCharacter();
}
// Update is called once per frame
void Update()
{
}
public void GenCharacter()
{
Instantiate(PlayerList[PlayerPrefs.GetInt("SelectCharacter", 0)], new Vector3(3.0f, 11.28f, 1.18f), transform.rotation);
}
} Any help is appreciated