I wanted to code that the collision doesn´t collide the Player but whenever I try it the error comes
that’s where the error comes from:
I wanted to code that the collision doesn´t collide the Player but whenever I try it the error comes
that’s where the error comes from:
If I’m not mistaken, Physics2D.Raycast returns a RaycastHit2D and you’re checking for a bool value at the beginning of your IF statement Wallcheck == false
. Does this not throw an error?
I think the NullReferenceException might appear because (A) there’s no collision happening and Wallcheck is null or (B) no RigidBody2D was set on the object with the script attached.
Try checking if Wallcheck != null
before anything else.