NullReferenceException
I am trying to run a root motion with an animator using the ThirdPersonCharacter script from the Standard Assets.
Here is what it is saying:
NullReferenceException: Object reference not set to an instance of an object UnityStandardAssets.Characters.ThirdPerson.ThirdPersonCharacter.CheckGroundStatus () (at Assets/Standard Assets/Characters/ThirdPerson/ThirdPersonCharacter.cs:215) UnityStandardAssets.Characters.ThirdPerson.ThirdPersonCharacter.Move (Vector3 move, Boolean crouch, Boolean jump) (at Assets/Standard Assets/Characters/ThirdPerson/ThirdPersonCharacter.cs:54) UnityStandardAssets.Characters.ThirdPerson.basicAI.Patrol () (at Assets/Standard Assets/Characters/ThirdPerson/basicAI.cs:68) UnityStandardAssets.Characters.ThirdPerson.basicAI+c__Iterator0.MoveNext () (at Assets/Standard Assets/Characters/ThirdPerson/basicAI.cs:52) UnityEngine.MonoBehaviour:StartCoroutine(String) UnityStandardAssets.Characters.ThirdPerson.basicAI:Start() (at Assets/Standard Assets/Characters/ThirdPerson/basicAI.cs:42)
Here is my code: void CheckGroundStatus() { RaycastHit hitInfo; #if UNITY_EDITOR // helper to visualise the ground check ray in the scene view Debug.DrawLine(transform.position + (Vector3.up 0.1f), transform.position + (Vector3.up 0.1f) + (Vector3.down m_GroundCheckDistance)); #endif // 0.1f is a small offset to start the ray from inside the character // it is also good to note that the transform position in the sample assets is at the base of the character if (Physics.Raycast(transform.position + (Vector3.up 0.1f), Vector3.down, out hitInfo, m_GroundCheckDistance)) { m_GroundNormal = hitInfo.normal; m_IsGrounded = true; m_Animator.applyRootMotion = true; } else { m_IsGrounded = false; m_GroundNormal = Vector3.up; m_Animator.applyRootMotion = false; } }
Your answer
Follow this Question
Related Questions
Not sure why i'm getting NullReferenceException 0 Answers
Object reference not set to an instance of an object C# 0 Answers
NullReferenceException: Object reference not set to an instance of an object error ? 1 Answer
Help with my PopUp Damage Text! 0 Answers
A problem "NullReferenceException: Object reference not set to an instance of an object(...)" 0 Answers