- Home /
Question by
nizameddinkale · Mar 16, 2019 at 06:28 AM ·
c#animationnullreferenceexceptionboolean
Can't get boolean of an animator from other class
Hello everyone. I'm trying to get boolean of animator (below). If i use GetBool at AnimationControl class boolean is false but at CameraShake class im getting NullReferenceException error (Codes at below). I would appreciate any help.
AnimationContol.cs (attached like at pic)
public class AnimationControl : MonoBehaviour
{ public Animator animator;
//im using this to access Animator Component. this is an one line script for now.
}
CameraShake.cs(attached to CameraShake)
public class CameraShake : MonoBehaviour
{public AnimationControl animationControl;
void Update() {
//NullReferenceException: Object reference not set to an instance of an object CameraShake.Update ()
if (animationControl.animator.GetBool("isForestAnimCompleted"))
{// a function
} } }
screenshot-8.png
(138.1 kB)
Comment