- Home /
Question by
Paul_BadBoy · Aug 25, 2014 at 11:55 AM ·
animationjavascripterrorontriggerenterplay
Play Animation on trigger enter
Hello, i want to play an animation (elevator) when a specific object enters the trigger, but the animation plays when i press the play button.
function OnTriggerEnter (other : Collider) {
if(other.tag == "target")
{
Animation.PlayMode("lift")
}
}
If I have Animation.Play it gives me an error:"An instance of type UnityEngine.Animation is required to acces non-static member Play"
Any ideas?
Comment
that means you need Animation object to call its method cause they are not static
Best Answer
Answer by vinod.kapoor · Aug 25, 2014 at 01:17 PM
use animation.Play instead of Animation.Play (condition apply....you should have an animation type component attached to lift)
I think my animation plays automatically, i tried animation.play and I don't get any error. But I don't know how to disable the auto-play