The Camera Distance patch takes an object as an input and outputs the distance between the object’s position along the X, Y and Z axis and the camera. Use this patch to build a world effect enabling users to easily interact with objects in the scene.
Name | Description |
---|---|
Object | The scene object you want to use. |
Name | Description |
---|---|
Distance | The distance between the camera and the object in meters. |
In the example below, the Camera Distance patch is used in an effect containing audio and screen interactions to control position of the object. The volume of the speaker playing audio increases from 0 to 1 as the user drags the blue object towards the camera and vice versa.
To build a graph that causes the volume to decrease as the object’s camera distance increases, we connected:
If we directly mapped the Camera Distance to the Volume without adding the intermediary patches, the volume would increase as the distance increases.
Instead we simulate a real-world scenario where the volume decreases as the object moves away from the camera, using the following patches: