Can somebody help me with a script to make the main camera follow an object through script without it needing to be a child of the object? This is for a top down shooter. I’ve tried a lot of things that I thought would work and when they didn’t I looked on the forums and found only pretty much what I’ve thought of myself.
Here’s what I have tried and various similar variations of it:
Vector3 cameraPos = Camera.mainCamera.transform.position;
cameraPos.x = player.transform.position.x;
cameraPos.z = player.transform.position.z;
(in the Update function)
By variations I mean of the variable like: cameraPos = transform.position;