- Home /
Problem with animation..
sorry for this, please share your wisdom guys.. Ive been trying to make this work the whole day.. from reading every forum and watching many videos i still cant find a way to make this work on my own..
var obj : Transform;
function OnTriggerEnter(other : Collider){
obj.animation.Play("openDoors");
};
i wa trting to animate my door with trigger once the character enters collider but once it was triggered i did not see the animation instead my character went through the door, i dont know what happend because when i was trying to do this earlier when my code for the trigger is not yet working and not triggering and cant access the animation from the game object my character/first person controller cant go through the doors.. what should i do?
i tried changing the
var obj : Transform;
to:
var obj : GameObject;
and got the same result... Y_Y,
Answer by azmat786n · Dec 09, 2012 at 04:26 AM
//need to place this function in your script at the end or begin
//function about play animations
function PlayAnimation(AnimName : String) {
if (!animation.IsPlaying(AnimName))
animation.CrossFadeQueued(AnimName, 0.3, QueueMode.PlayNow);
}
/////now when you want to play any animation call a function
//for example.
function Start() {
PlayAnimation("run");
}
//remember one more thing you must apply this script on that object which have animations..
//hope this is helpful.