When using Cinemachine, the camera is not stable across Update() calls, so raycasts will not be accurate. This subclass changes the selector to use CinemachineCore.CameraUpdatedEvent to run the raycast instead.
CinemachineSelector.cs
Code: Select all
using Cinemachine;
namespace PixelCrushers.DialogueSystem
{
public class CinemachineSelector : Selector
{
protected override void OnEnable()
{
base.OnEnable();
CinemachineCore.CameraUpdatedEvent.AddListener(OnCameraUpdated);
}
protected override void OnDisable()
{
base.OnDisable();
CinemachineCore.CameraUpdatedEvent.RemoveListener(OnCameraUpdated);
}
private void OnCameraUpdated(CinemachineBrain cinemachineBrain)
{
base.Update();
}
protected override void Update()
{
}
}
}