public class CameraController : MonoBehaviour
public GameObject cars;
selectedCar = PlayerPrefs.GetInt("selectedCar");
target = cars[selectedCar].transform;
In my game I have a character select scene where I run through a list of objects and when one is selected it is stored into an int which I labeled selectedCar which is an index in the list cars. In the script above I am basically accessing that selectedCar variable and getting its transform so that I can use the transform.LookAt function and make the camera follow the player. In the inspector I can see that when the scene loads up it does in fact set “target” to the transform of the selected car but the camera does not follow. I tested my code without a list just purely dragging and dropping a transform in and that worked fine. Im curious as to why it will not work even though the camera has a target(transform) to follow.