- Home /
how to get a animation from other script on colision
Hi, I need help to get an animation from an other script to play on colision
the obstacle script
if(object == colision.name){
colision.GetComponent("character").GetComponentInChildren["1"].animation.CrossFade("win", 0.3);
Comment
Answer by Anxo · Jun 15, 2011 at 10:27 PM
Ok , you cant test fore collisions on a 3rd party object but you can ask the colliding object to send a function to your desired object. Lets say you want Object A to animate when Object B collides with Object C. you can use BroadcastMessage like this
//this script is on object B
var ObjectA : GameObject;
function OnCollisionEnter(collision : Collision){
if(collision.CompareTag("ObjectB"))
{
ObjectA.BoradcastMessage("Animate");
}
}
this will send a message to ObjectA to run the function "Animate".
Your answer
Follow this Question
Related Questions
Animation / Distance 0 Answers
How to call animation from another Script in C#? 1 Answer
enemy shoots with animation 1 Answer
How to click a 3d object in unity3d? 3 Answers
zombie script problem 0 Answers