So I get the gist. Make a hand container, parent it to the player, set the gun to the hand container. But, how should I handle the weapon camera? Should I have it parented to the hand camera, or should I have it the same location as the player camera? So many questions
Camera stuff is pretty tricky… 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.
What do you mean by weapon camera? Do you mean the overlay camera used for camera stacking?
As a rule of thumb: Camera is an object at the root of the scene at all times. Cinemachine actually assumes the camera to be at the root and while it can be made to work otherwise, it’s not recommended for the same reason it’s not recommended to parent a camera in general:
Sooner or later you’ll want to use a different camera, and then it’ll get complicated switching between the two.
Or you may need to detach the camera from the object it is tracking. For instance the player dies and you don’t want the camera to roll along with the player’s ragdoll, you’d have to detach it. And then reattach it again.
Just the tip of the iceberg issues complicating camera work when it is parented. ![]()