Hello,
I would like to control the Animator component of an object’s child.
In the Hierarchy:
I have the object (Cube, w/o the render and material component) called Movement, and it has a child, that is the one i’d like to animate:
public var anim : Animator;
// ...
//giving value to the "anim" for(var
childf : Transform in transform){
if(childf.gameObject.tag == "Player")
{
child = childf;
} else if(childf.gameObject.tag == "MainCamera"){
cam = childf;
}
}
anim = child.GetComponent(Animator);
//Trying to make the character move
anim.SetFloat(hash.speedFloat, 5.5f);
When i hit play, and want to move the character, it drops an error
NullReferenceException: Object reference not set to an instance of an object Movement.Movement (Single ver, Single hor, Boolean sneak, Boolean jump) (at Assets/Done/DoneScripts/PlayerScripts/Movement.js:37) Movement.FixedUpdate () (at Assets/Done/DoneScripts/PlayerScripts/Movement.js:30)*
This code is based on the Project:Stealth Tutorial, and needless to say, the character is not moving