Control Animator of seperate GameObject

All, I have an object (A) which collides with Object (B). I want this collision to change the animation on Object (C).

I have colliders set on Objects A & B, and animations within Mechanim on Object C.

I have the follow script which does not work.

Animator = anim;
public Gameobject Sphere;
//this is my Object (C) on which I what to change the animation state.

void OnCollisionEnter(Collision obj)
{

if (obj.gameObject.tag == “Activity”)
//object (B) is tagged activity

{
Sphere.GetComponent();
anim.SetBool (“IsMoving”, true);

//where “IsMoving” is a parameter in mechanim currently set to false on the transition.
}

Any help greatly appreciated.

Please look over this page for how to add code to the forums. It will display much nicer to view/read :slight_smile:

Not sure what “Animator = anim” is supposed to be. That is invalid code.
You could set the Animator:

public Animator anim; // drag the sphere animator here in the inspector
// then, just call it in the if statement:
anim.SetBool("IsMoving", true);

depending on if you took liberties pasting the code here or what not…
your line

Sphere.GetComponent<Animator>();

Could have been :

anim = Sphere.GetComponent<Animator>();
anim.SetBool(  // etc
// or ...
Sphere.GetComponent<Animator>().SetBool("IsMoving", true); // like that..