- Home /
Question by
Blakester53 · May 17, 2014 at 11:22 PM ·
animationfirst-person-controllerfirst-personfirst person shooter
Having an Animation play when close to 1st person controller
I would like it so when you get close to an object, it would play an animation once. I'm just not sure how I would accomplish this, or even if this is possible. If anyone knows how, it would be awesome. Thanks!
Comment
Answer by Jeff-Kesselman · May 17, 2014 at 11:25 PM
Step 1: Create an animation for the object. Give it a name in the Animator compoent.
Step 2: Create a sphere collider thats the right size, attached to your object. Set it as a trigger
Step 3: Write an OnTriggerEnter script to respond when someone enters the sphere http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html
Use http://docs.unity3d.com/Documentation/ScriptReference/Animator.Play.html to play the animation in the OnTriggerEnter routine,