Hello,
Is it possible to place FreeLook camera to given Vector3 at runtime? I sometimes need to show camera’s target from specific distance and angle, but let player to control the camera (zoom and rotation https://snaptube.cam/ ).
I know that it should be possible to use Inherit Position to keep camera transform position when script is initialized, but is it possible to override camera transform if camera is live?
You should switch to a vcam, that is positioned there, that can zoom and rotate. Then, when you’d like to go back to your freelook, you switch back.
If you’d like to move Freelook within its constrains, then you can try: freelook.ForceCameraPosition(position, rotation) This will move your Freelook to the closest point on the rig defined by freelook to the target position.
This ForceCameraPosition method did not seem to work on my camera manager Start. Every time I start the level, the freelook surprises me from some new angle I had no intention of using.
It’s Cinemachine 2.8.9 on 2021.3 LTS. I think it’s because I use ‘Inherit Position’ for all the other times in the scene where I want to transition back to the FreeLook from specialty cameras. I would have thought that ForceCameraPosition would basically overrule the Inherit Position lerp but that doesn’t seem to be the case. With all these VCams in the scene for various purposes, moving the Main Camera around in the Editor is useless or impossible.
My workaround is on Start(): calculate the position, shove the Main Camera there ignoring whatever Cinemachine would rather do with it, and then use ForceCameraPosition on the FreeLook VCam.
It depends on the order things get called. If you’d like to ensure that ForceCameraPosition wins, then you can hook into the OnCameraLive event and call your ForceCameraPosition script from there.
Why are you using Inherit Position and also try to ForceCameraPosition at the same time?
Note: In Cinemachine 2.9.2 and above ForceCameraPosition is faster and more precise than in previous versions. So if you rely on it a lot, I recommend upgrading your Cinemachine version.
At the start of a scene load, I don’t want my camera to be at some random Editor-driven position because I accidentally soloed some VCam again. I want it squarely behind the position I have set my character, always, every time, from frame 1. At most/all other times, the game has just toggled on or toggled off a specialty camera, like “look at the ladder I am climbing” or “look at the enemy I am aiming at”, and I want to inherit.
The other janky solution would be to turn off Inherit in the Editor, and then in a coroutine turn it back on after scene load. Again, I just thought that ForceCameraPosition would just say “yanno, screw the inherit this time and move the camera,” as the name implies. If your Inherit is a coroutine, ForceCameraPosition should just stop it.