Answer the question
In order to leave comments, you need to log in
Object reference not set to an instance of an object. How is this possible?
Checking if an object is not null. And the call line gives an error:
Object reference not set to an instance of an object.
How is this even possible?
if(HitMirrorBP != null)
{
HitMirrorBP.Mirror();
}
Answer the question
In order to leave comments, you need to log in
maskHit = Physics2D.Raycast(transform.position, Vector2.down, 10f, NeedLayer);
if (maskHit.transform != null)
{
if(maskHit.collider.tag == "Mirror")
{
Debug.DrawLine(transform.position, maskHit.point, Color.red);
HitMirrorBP = maskHit.transform.GetComponent<Mirror_BP>();
if(HitMirrorBP != null)
{
HitMirrorBP.Mirror();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question