- Home /
Getting My FPS Controller To Play An Animation After A Trigger Event
Okay so I'm not yet fully accompanied with scripting, if anything I use Java. But my issue is, is that I wanna make it so that when my fps controller passes a trigger, the fps controller itself plays an animation. I don't know any script that would help so I'm asking the community, please help if its not much.
there is no Java in Unity, only javascript, which is different, or c# (which is microsoft's answer to Java, and almost identical)
Answer by Guzaii · Oct 16, 2013 at 03:45 PM
if its an animation for the "Player" (where like the camera moves). Then try this: Make and Put an animation on the "Player", and then put this script on the object "Player"
#pragma strict
var animationName : String;
function OnTriggerEnter(theCollider : Collider)
{
animation.Play (animationName);
Debug.Log("Triggered");
}
(Remember to put "Is Trigger" on the Collider. And make the animation, from where the Collider starts) Hope this helps you, and if not. Then just tell me :) (Also, dont set the animation to "Play Automatically")
Thanks but it didn't end up working. Like a question about the script, when it says "theCollider" is that the tag for the collider being used as the trigger?
Sadly that just a collider.. not a specific. I am still trying to figure that out :) But this was all i could help with, and if i test it. It works for me.
Okay thanks anyways man, Ill just have to experiment with it myself haha.
Your answer
Follow this Question
Related Questions
Trigger door animation with external trigger 1 Answer
OnTriggerStay and OnTriggerEnter won't react when the player enters them. 1 Answer
Why does my climb stairs animation not play? 1 Answer
Play parent animation without affecting the child animation 1 Answer
How to start an animation of the object itself by trigger enter in #C? 1 Answer