[REMOVE]

Hi,

I am getting this error with this code:

Player player = playerObj.GetComponent<Player> ();
float closestCubeArrivalAtTime = player.closestCube.GetComponent<CubeMovement> ().arrivalAtTime;

I want to acces the variable ‘‘arrivalAtTime’’ of the closestCube…

Everything is assigned…

What to do?

Player, playerObj, or closestCube.CubeMovement doesn’t exist.

Null Reference exceptions are always solvable exactly the same way, you don’t need to make threads for them. Simply do your get component calls and do a Debug.Log() of the variable before trying to use it. You will find the null reference easily.

The strange thing is that I only ask the arrivalAtTime of the closestCube, but it gives me all the cubes. Debug.Log(player.closestCube) just gives me only the closestCube.

Ah… im stupid… the first cube didn’t had that script… I’m removing this thread since it’s useless… thanks for trying to help.

Ok I can’t remove the thread xD