Set FreeLook camera position at runtime.

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).

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?

CM 2.6.3 has a new API: FreeLook.ForceCameraPosition that should do the job.

        /// <summary>
        /// Force the virtual camera to assume a given position and orientation. 
        /// Procedural placement then takes over
        /// </summary>
        /// <param name="pos">Worldspace pposition to take</param>
        /// <param name="rot">Worldspace orientation to take</param>
        public override void ForceCameraPosition(Vector3 pos, Quaternion rot)
1 Like

Wow, that method even has the same name as one I prepared to manage it :slight_smile:
Works great. Thanks, Gregory.

2 Likes

@Gregoryl How would you do the same for a Cinemachine Virtual Cam? Using ForceCameraPosition does nothing. Thanks!

It should work the same way for non-FreeLook vcams.