xpsarin
February 12, 2013, 7:52pm
1
How do i play an animation OnTriggerEnter()
i tryed this:
function OnTriggerEnter(collision : Collider)
{
if(collision.transform.name == "Ball")
{
Debug.Log("cyl hit! :smile:");
audio.Play();
//Animation play...
animation.Play("CylAnim2");
}
}
also tryed to remove the “CylAnim2” and there is only one animation on this object
the audio is playing but the animation is not
Try using
anim.Play('Walk");
Though I’ve been using the following to check its not already playing (I had an issue where it kept restarting on the first frame and thus looked static).
if (!anim.IsPlaying("Walk")) anim.Play('Walk")'
Hope that works for you
xpsarin
February 12, 2013, 9:25pm
3
Thanks for the reply
if i just do anim.Play(“CylAnim2”); it gives me an error:
Assets/Scripts/bonusCyl.js(12,17): BCE0005: Unknown identifier: ‘anim’.
any idea ;o?
Oh, you’ll have to define what anim represents first.
As currently anim is pointing to nothing as its not previously referenced in the script.
I’m still very basic in scripting knowledge so unfortunately I don’t think I’ll be able to help much more than this.
xpsarin
February 12, 2013, 10:21pm
5
ahh okay, I’m new to scripting ;o, trying to fix this but no luck