Getting the highest-priority camera #344
-
Considering some relatively recent changes (including the introduction of the PhantomCameraManager), what is the best way to go about getting the highest-priority camera currently in the scene tree? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It depends a bit on the scene structure and whether if you have both a PhantomCameraManager.phantom_camera_hosts[0].get_active_pcam() Which fetches the currently active Otherwise, if you only got var pcams_by_priority: Array
pcams_by_priority = PhantomCameraManager.phantom_camera_3ds
pcams_by_priority.sort_custom(
func (a: PhantomCamera3D, b: PhantomCamera3D):
return a.priority > b.priority
) Then you can just grab the first index item of the array with Could probably make an internal public getter function that does the above to make that easier. |
Beta Was this translation helpful? Give feedback.
-
Thanks so much! |
Beta Was this translation helpful? Give feedback.
It depends a bit on the scene structure and whether if you have both a
PCamHost
and thePCams
in the scene, but you could for example do:Which fetches the currently active
PCam
, i.e. thePCam
with the highest priority in the scene.Otherwise, if you only got
PCams
in a scene, you would currently have to filter the list by doing something like:Then you can just grab the first index item of the array with
pcams_by_priority[0]
.