Collisions

Hi, all! I am in a little bit of a debacle here…

I have a prefab named platform. It is comprised of one split mesh, two bones, and a controller for the bones.
The bones play a trap dooor-like animation when the player lands on the platform. The problem is that the bone controller is the only thing that can play the animation, but the colliders need to belong to the bones. I had one script that was attached to the bones and set a variable on a collision another script belonging to the animation controller that played the animation when the variable was true. But when the player hit a platform, they all opened. This happened because all of the platforms read the variable as true.

Goals - I need the animation controller to play the animation when one of the bones collides with the player, but I only want THAT CONTROLLER to play it. Not all others.

How would I do this?

480074--16856--$diagram.png

No one knows?

I don’t understand what the problem is. A collider can trigger the animation to play, on one or all objects.

Really? How would I make it apply to all objects?

Can I make it so that when a collision is triggered on one object in a prefab, the animation is triggered in another one, higher up in the hierarchy of the prefab?

private var anim : Animation;

function Start() { 
  anim = transform.root.GetComponentInChildren( Animation );
}

function OnCollisionEnter( stuff ) {
  anim.Play( whatever );
}

That’ll get an arbitrary animation from the current object tree (any ancestor or descendant). Then you animate it. Yay. :slight_smile:

Your problem with all the things reading a var as true is that your variable was static. Static variables exist only once for all instances of a class, while class instances have a personal copy of each non-static variable.