Log in with itch.io to leave a comment.
looks great but I'm experiencing an issue. I attached a Screenshake script to my Main Camera, and when there is an explosion ingame I call my gamecontroller, which invokes Camera.current.Shake();
On 2/3 of the explosions it works, but sometimes it doesn't and I get the following error:
NullReferenceException: Object reference not set to an instance of an object
ScreenshakeCameraExtentions.Shake (UnityEngine.Camera cam) (at Assets/Clavian/Screenshake/ScreenshakeCameraExtentions.cs:9)
GameController.Explosion () (at Assets/Scripts/GameController.cs:51)
DestroyByContact.OnTriggerEnter (UnityEngine.Collider other) (at Assets/Scripts/DestroyByContact.cs:34)
Line 9 of ScreenshakeCameraExtentions does this:
Screenshake shake = cam.transform.GetComponent<Screenshake>();
Any idea why it's failing to get the Screenshake component?
Looked into it, and the problem seems to be that Camera.current is meant for low-level render control, only: https://docs.unity3d.com/ScriptReference/Camera-cu...
Instead of using Camera.current, try using Camera.main or a public Camera variable!