[HELP NOT SOLVED] Simple Question on Animator Controller

Hi all,

I’m bush-bashin away trying to learn the Animator Controller and Linking it with Javascript.

I can make the code work when it’s directly on the character object but how do i do it if it’s assigned to the camera?

Ive tried this with no luck:

var animator : Animator;

function Start () {

animator = GameObject.Find("CharacterRigged"); 
animator = GetComponent("Animator");

animator.SetBool("Jump", false);

}

Please oh please oh please can somebody help! Ive been banging my head for days!!

Ill buy you a beer! :wink:

animator = GameObject.Find(“CharacterRigged”);

That finds a game object (of type “GameObject”) and tries to assign it to the variable “animator” which is of type “Animator”. That won’t work.

animator = GetComponent("Animator");

That tries to find a component “Animator” on the own game object (the one that this script is assigned to) and stores it in the variable.

What you need is to first store the other “CharacterRigged” - gameObject in another variable. And then call GetComponent on this variable to get the component of this other object:

var characterRiggedGameObject : GameObject;
characterRiggedGameObject = GameObject.Find("CharacterRigged");
animator = characterRiggedGameObject.GetComponent(Animator);

(Note also the missing " in GetComponent. They are not needed here anyway… ;))