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.
- Listed in Customization and screenshots
- Inherits or implements
NetworkEntityBehaviour
Constructors
| Member | What it is |
|---|---|
OpticalZoom() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
11 private and internal fields
| Member | What it is |
|---|---|
private PickupDock dock | The dock the zoom attachment goes into. |
private static Renderer[] emptyList | Shared empty renderer array used when nothing is docked. |
private float originalFOV | The camera's field of view without zoom. |
private Vector3 popAngularAxis | Axis of the torque applied when popping, relative to the camera's flattened facing. |
private float popAngularStrength | Torque strength when popping. |
private float popStrength | Force strength when popping. |
private Vector3 popVelocity | Direction of the pop force, relative to the camera's flattened facing. |
private IEnumerable<Renderer> renderers | Renderers of the docked attachment that get hidden during renders. |
private MethodSyncStruct<uint> syncPop | Message the server sends so clients pop the attachment too. |
private Camera targetCamera | The camera whose field of view changes. |
private float zoomedFOV | Field of view while the zoom is docked. |
Methods
| Member | What 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
| Member | What 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. |