Skip to main content

OpticalZoom

A class in Root.Township, Alta.ScreenshotCamera.

Zoom lens dock on the hand camera: docking a zoom attachment narrows the camera's field of view and hides the attachment from the camera's render. When the camera is destroyed the server pops the attachment off.

Constructors​

MemberWhat it is
OpticalZoom()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

11 private and internal fields
MemberWhat it is
private PickupDock dockThe dock the zoom attachment goes into.
private static Renderer[] emptyListShared empty renderer array used when nothing is docked.
private float originalFOVThe camera's field of view without zoom.
private Vector3 popAngularAxisAxis of the torque applied when popping, relative to the camera's flattened facing.
private float popAngularStrengthTorque strength when popping.
private float popStrengthForce strength when popping.
private Vector3 popVelocityDirection of the pop force, relative to the camera's flattened facing.
private IEnumerable<Renderer> renderersRenderers of the docked attachment that get hidden during renders.
private MethodSyncStruct<uint> syncPopMessage the server sends so clients pop the attachment too.
private Camera targetCameraThe camera whose field of view changes.
private float zoomedFOVField of view while the zoom is docked.

Methods​

MemberWhat it is
override void Initialize()Sets up the pop effect message.
override void InitializeAsServer(SpawnData spawnData)Server: hooks the parent prefab's pre-destroy event to EmptyOut.
10 private and internal methods
MemberWhat it is
private void Awake()Client: stores the original field of view and hooks the dock's docked and undocked events.
private void DockZoom(Interactor interactor, Pickup pickup, PickupDock dock)Sets the zoomed field of view and starts hiding the docked attachment's renderers during camera renders.
private void EmptyOut(NetworkPrefab prefab)Server: when the camera prefab is about to be destroyed, undocks the attachment, pops it and tells clients to pop it too.
private void OnDestroy()Unhooks the camera render events.
private void OnDrawGizmosSelected()Editor only: draws the pop direction.
private void PopZoom(Pickup zoom)Pushes the attachment away with force and torque along the pop settings. On clients it also blends rigidbody authority.
private void PostRender(HandCamera handCamera, HandCameraEvent cameraEvent)Turns the attachment's renderers back on after this camera renders.
private void PreRender(HandCamera handCamera, HandCameraEvent cameraEvent)Turns the attachment's renderers off before this camera renders, so the lens does not see itself.
private void SyncPop(IPlayer player, Stream stream, uint entityIdentifier)Message handler. Client: finds the attachment entity by identifier and pops it.
private void UndockZoom(Interactor interactor, Pickup pickup, PickupDock dock)Restores the original field of view and stops hiding renderers.