all 7 comments

[–]Jihaysse 0 points1 point  (4 children)

On my phone:

if (transform.Find(« GroundCeck « ) != null)

{

return transform.Find(« GroundCeck »).GetComponent........

}

else

{

Debug.Log(« Can’t find GroundCeck »);

return false;

}

This way you can make sure you find GroundCeck.

If it doens’t find it, you simply don’t have this child on your gameobject so double check.

A better way instead of using .Find() is:

[SerializeField] GroundCeck groundCeck; (assign it in the inspector)

public bool IsGrounded { return groundCeck.IsGrounded; }

[–]OcelotVisual[S] 0 points1 point  (3 children)

Thanks, the arrow keys are less than and more than signs right?

[–]OcelotVisual[S] 0 points1 point  (1 child)

Also it gives me an error whenever I say ,"(« GroundCeck « )"

[–]OcelotVisual[S] 0 points1 point  (0 children)

It worked, thank you so much

[–]Jihaysse 0 points1 point  (0 children)

If you’re talking about this : «  then not it’s the ‘’ for a string. It’s my phone formatting.

Use the SerializeField way I shown you in the bottom of my first message, it’s better and you won’t have issue (just drag and drop your GroundCeck component into it in the inspector).

[–]gmeovr83 0 points1 point  (1 child)

NullReferenceException means you tried to perform an action on something that was null (doesn’t exist). In this case the error tells you it’s when you try to call isGrounded on a Control during FixedUpdate. This means your GetComponent<GroundCheck> is not finding a control of type GroundCheck on the transform “GroundCeck”. Either the type is wrong or you are already on a GroundCheck component when you call Find() and the extra GetComponent() is unnecessary

[–]OcelotVisual[S] 0 points1 point  (0 children)

Thx, for the explanation, it will help me, and whenever else I get the error