Search Unity

Cinemachine events

Discussion in 'Cinemachine' started by etherElric, Oct 28, 2018.

  1. etherElric

    etherElric

    Joined:
    Mar 1, 2016
    Posts:
    2
    Does Cinemachine expose events when targets followed are outside the camera frame?
    I want to trigger something when the game objects the virtual camera follow get out of frame and back in the frame.
    I've setup my gameobjects like the 2DConfinerTargetGroup scene in the Cinemachine Examples (without the confiner script). So a CinemachineBrain, a CinemachineVirtualCamera and a CinemachineTargetGroup. The Virtual camera follows the target group (no lookat).

    Considering that it is possible to switch to a different camera when a target gets out of frame, I am guessing it is possible to hook on the event in my own code, but I do not see any events of the kind from the documentation.

    Anyone has a clue how to hook on those events?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    No events, but it's easy to attach a script to find out if your target is in frame and generate your own event. Just check the angle camera->target makes with camera forward. If it's greater than the FOV, then the target is offscreen.