I’ve been working on the tanks project that walks you through basically all the steps of how you can make a functional tanks game. it sounded sweet so i immediately started working on it, all was smooth until i had to target the tanks to the camera, i followed the steps as shown but yet the camera i had wouldn’t budge and it would stay still right where it was instead of following my tanks. I tried looking up if more people had this issue but i haven’t been able to find someone with the same issue, i even tried to copy the demo camera, which didn’t work either. Could anyone help?
Where? Unity Learn has “comments” section for each step of the tutorial as I remember. Did you look at those sections?
Also you can pass the course differently on Unity Learn:
-
In-Editor (if supported) and Web passing the course can provide different information on Unity Learn.
-
Information for different Unity versions on Unity Learn (switcher in UI on the website) can also be different.
So try to check different sources.
That demo predates the latest Camera stuff using Cinemachine.
You might want to gently disable the existing Camera stuff and integrate your own Cinemachine version…
I hear all the Kool Kids are using Cinemachine from the Unity Package Manager.
There’s even a dedicated Camera / Cinemachine area: see left panel.
Here’s a survey of Cinemachine Camera types:
If you absolutely insist on making your own camera controller, do not fiddle with camera rotation.
The simplest way to do it is to think in terms of two Vector3 points in space:
- where the camera is LOCATED
- what the camera is LOOKING at
private Vector3 WhereMyCameraIsLocated;
private Vector3 WhatMyCameraIsLookingAt;
void LateUpdate()
{
cam.transform.position = WhereMyCameraIsLocated;
cam.transform.LookAt( WhatMyCameraIsLookingAt);
}
Then you just need to update the above two points based on your GameObjects, no need to fiddle with rotations. As long as you move those positions smoothly, the camera will be nice and smooth as well, both positionally and rotationally.