[HOWTO] How To: Use Cinemachine with the Dialogue System
Re: How To: Use Cinemachine with the Dialogue System
Hi,
Would you please click on the NullReferenceException in the Console window, press Ctrl+C (or Cmd+C on Mac) to copy the details to the clipboard, and then paste them into a reply?
Would you please click on the NullReferenceException in the Console window, press Ctrl+C (or Cmd+C on Mac) to copy the details to the clipboard, and then paste them into a reply?
Re: How To: Use Cinemachine with the Dialogue System
Here's two older prints I had of the error. Sorry if the first one is hard to read.
Re: How To: Use Cinemachine with the Dialogue System
Please post the text from the clipboard, not a screenshot. Thanks!
Re: How To: Use Cinemachine with the Dialogue System
Sorry about that. Here's the full Console Log. Do tell if I need to post something else. To reiterate: the dialogues are the only thing triggering this error so far.
NullReferenceException: Object reference not set to an instance of an object
CinemachineShake.ShakeCamera (System.Single intensity, System.Single time) (at Assets/Scripts/CinemachineShake.cs:30)
HutongGames.PlayMaker.Actions.ShakeCam_PM.CallShake (System.Single intensity, System.Single time) (at Assets/Scripts/PlayMaker Actions/ShakeCam_PM.cs:21)
HutongGames.PlayMaker.Actions.ShakeCam_PM.OnEnter () (at Assets/Scripts/PlayMaker Actions/ShakeCam_PM.cs:15)
HutongGames.PlayMaker.FsmState.ActivateActions (System.Int32 startIndex) (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
HutongGames.PlayMaker.FsmState.OnEnter () (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state) (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState) (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
HutongGames.PlayMaker.Fsm.UpdateStateChanges () (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
HutongGames.PlayMaker.Fsm.FixedUpdateState (HutongGames.PlayMaker.FsmState state) (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
HutongGames.PlayMaker.Fsm.FixedUpdate () (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
PlayMakerFixedUpdate.FixedUpdate () (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
NullReferenceException: Object reference not set to an instance of an object
CinemachineShake.ShakeCamera (System.Single intensity, System.Single time) (at Assets/Scripts/CinemachineShake.cs:30)
HutongGames.PlayMaker.Actions.ShakeCam_PM.CallShake (System.Single intensity, System.Single time) (at Assets/Scripts/PlayMaker Actions/ShakeCam_PM.cs:21)
HutongGames.PlayMaker.Actions.ShakeCam_PM.OnEnter () (at Assets/Scripts/PlayMaker Actions/ShakeCam_PM.cs:15)
HutongGames.PlayMaker.FsmState.ActivateActions (System.Int32 startIndex) (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
HutongGames.PlayMaker.FsmState.OnEnter () (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state) (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState) (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
HutongGames.PlayMaker.Fsm.UpdateStateChanges () (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
HutongGames.PlayMaker.Fsm.FixedUpdateState (HutongGames.PlayMaker.FsmState state) (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
HutongGames.PlayMaker.Fsm.FixedUpdate () (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
PlayMakerFixedUpdate.FixedUpdate () (at <7e9e696ff1a04620968849cd9bbf2ab4>:0)
Re: How To: Use Cinemachine with the Dialogue System
The error is here:
CinemachineShake.ShakeCamera (System.Single intensity, System.Single time) (at Assets/Scripts/CinemachineShake.cs:30)
What is CinemachineShake? It looks like a custom script. Can you share the code?
CinemachineShake.ShakeCamera (System.Single intensity, System.Single time) (at Assets/Scripts/CinemachineShake.cs:30)
What is CinemachineShake? It looks like a custom script. Can you share the code?
Re: [HOWTO] How To: Use Cinemachine with the Dialogue System
Sorry for the late reply. Here is the code for the Cinemachine Shake script.
The problem is when it tries to change the amplitude gain, apparently, but what's got me stumped is that I don't think the dialogues should be interfering in Cinemachine's Basic Perlin. Maybe there's something I'm not seeing?
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class CinemachineShake : MonoBehaviour
{
public static CinemachineShake Instance { get; private set; }
private CinemachineVirtualCamera virtualCamera;
[SerializeField]
private CinemachineBrain cinemachineBrain;
private float shakeTimer;
private float shakeTimerTotal;
private float startingIntensity;
private void Awake()
{
Instance = this;
cinemachineBrain = GetComponent<CinemachineBrain>();
}
public void ShakeCamera(float intensity, float time)
{
virtualCamera = (CinemachineVirtualCamera)cinemachineBrain.ActiveVirtualCamera;
CinemachineBasicMultiChannelPerlin cameraShake = virtualCamera.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
cameraShake.m_AmplitudeGain = intensity;
startingIntensity = intensity;
shakeTimerTotal = time;
shakeTimer = time;
}
public void ShakeCamera(CameraShakeParams settings)
{
ShakeCamera(settings.intensity,settings.duration);
}
private void Update()
{
if (shakeTimer > 0)
{
shakeTimer -= Time.deltaTime;
if (shakeTimer <= 0)
{
CinemachineBasicMultiChannelPerlin cameraShake = virtualCamera.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
cameraShake.m_AmplitudeGain = Mathf.Lerp(startingIntensity, 0f, 1- (shakeTimer / shakeTimerTotal));
}
}
}
public void SetInstance()
{
Instance = this;
}
[System.Serializable]
public struct CameraShakeParams
{
public float intensity;
public float duration;
}
}
Re: [HOWTO] How To: Use Cinemachine with the Dialogue System
What's the reason for calling SetInstance in the Dialogue System Trigger?
Can you remove it? I suspect that SetInstance is setting CinemachineShake to a value that later becomes invalid.
Can you remove it? I suspect that SetInstance is setting CinemachineShake to a value that later becomes invalid.
- PayasoPrince
- Posts: 104
- Joined: Thu Jan 27, 2022 6:47 pm
Re: [HOWTO] How To: Use Cinemachine with the Dialogue System
This thread was useful for me and helped me use Cinemachine with The Dialogue System.
Is there a way to pin this?
Is there a way to pin this?
Re: [HOWTO] How To: Use Cinemachine with the Dialogue System
There are a lot of HOWTO threads, especially in the Dialogue System for Unity forum section. Instead of pinning them all (which would fill up the first several pages of the forum), you can enter "HOWTO" in the search bar to see all How To articles.
Re: [HOWTO] How To: Use Cinemachine with the Dialogue System
Sorry for reviving a 2year old thread (which was already revived this past january)
I am trying to find how to "freeze" cinemachine virtual camera movement during cutscene (dialogues)
Our cinemachine vcam has a variable horizontal axis on Mouse X from -45 to 45 angle, and it keeps moving even during dialogues... any suggestion to freeze it would be greatly appreciated!
I am trying to find how to "freeze" cinemachine virtual camera movement during cutscene (dialogues)
Our cinemachine vcam has a variable horizontal axis on Mouse X from -45 to 45 angle, and it keeps moving even during dialogues... any suggestion to freeze it would be greatly appreciated!