Whne moving the SkyCar code I get NullRef on "m_CharacterAnimatorMonitor"

I am attempting to edit the Skycar script but when I move the script to another vehicle I get the error
"NullReferenceException: Object reference not set to an instance of an object".
When I check, the m_CharacterAnimatorMonitor it is my problem. It is located in Skycar.cs at

Code:
/// <summary>
        /// Updates the animator.
        /// </summary>
        public void Update()
        {
                      m_Animator.SetFloat(m_HorizontalInputID, m_CharacterAnimatorMonitor.AbilityFloatData, 0, 0);
        }

I need to know where this is being set and why just moving to another Copy of Skycar can not find it.

I see that "EnteredVehicle(GameObject character)"
sets it but that looks like it is only AFTER that character has entered the Vehicle. The code above runs in Update.

Why doesn't the original SkyCar.cs error out like my copy if "m_CharacterAnimatorMonitor"
isn't set until after the player has entered the vehicle?
I'm a bit confused



Any help is appreciated.
 
Last edited:
The Skycar is just a reference implementation and not intended for productive use, so for instance there is no NullRef check. The error does not occur in the demo, as the component is disabled unless the player has entered the car (done in the EnableDisable method, which is called after the animator monitor has been assigned).

Why it's not working on your car is hard to say, because you mentioned that you edited the script. Before you modify anything, or setup your own car, make sure you understand the demo car.

The animator monitor is set in the EnteredVehicle method.
 
Top