-1
\$\begingroup\$

I'm getting error an error on this piece of code:

if (EventSystem.current.IsPointerOverGameObject())
     return;

The error: NullReferenceExpection: object reference not set to an instance of an object playercontroller.update() { at assets/script/palyer/playercontroller.cs:21)

Any solution to this?

\$\endgroup\$
2
\$\begingroup\$

The error message is there to tell you what the problem is. A NullReferenceException means you tried to access a variable that is currently null:

Object a = null;
a.ToString();  <-- this line throws a NullReferenceException!

So in your case, assuming EventSystem is a class, EventSystem.current is null.

As this is Unity, the most likely issue is that you haven't added an EventSystem to your current scene, so there is no current EventSystem.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.