-1

im having a problem, which i think might be that im not looking for the layer that the raycast is hitting, correctly

if (raycastHit.transform.gameObject.layer == groundMask)
            {
                Debug.Log("heavy");
                state = State.HookShotFlyingPlayer;
            }

No syntax problem, but a problem with unity. Its giving an error on

(raycastHit.transform.gameObject.layer == groundMask)

the error being

Object Reference not set to an instance of an object

1 Answers1

-1

Unity is throwing a null reference exception. This means that either raycastHit, transform or gameObject is null. You can set a break point before the if statement and examine what exactly is null.

  • i know this is probably a dumb question, but what is a break point? – TerazikMubaloo Dec 16 '21 at 17:11
  • A break point is an instruction for a debugger, which tells a debugger to pause the execution of the program. You place the break point at a given line and start the program in debug mode. The program will pause when the program execution reaches the line. You can then examine the state of the program and the variables in the current scope. Check [Debugging C# code in Unity](https://docs.unity3d.com/Manual/ManagedCodeDebugging.html) – Vladimir Stefanov Dec 16 '21 at 17:23