When I have this line of code inside fixed update I get an error in Unity:
if (active.transform.position.x <= -4)
{
Debug.Log(active.transform.position.x.ToString());
}
NullReferenceException: Object reference not set to an instance of an object Handler.FixedUpdate () (at Assets/Handler.cs:79)
When used inside lateupdate however, I do not receive an error.
Why would it do this? I am trying to move a RigidBody
using FixedUpdate
with
if (active.transform.position.x <= -4)
as a parameter.
My question is why am i getting a null exception inside fixedupdate but not lateupdate. I know what a null exception is.