Search Unity

Fadable animation

Discussion in 'Animation' started by Undiscovered, Oct 15, 2014.

  1. Undiscovered

    Undiscovered

    Joined:
    Apr 5, 2014
    Posts:
    53
    Hi

    We are looking to create a trigger based animation within unity where when the camera approaches 50 units from the (invisible) object it then animates. When the camera is then 5 units away from the object it then de-animates.

    Is this possible? How would I go about achieving this?

    Thanks
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,702
    Use SphereColliders with IsTrigger ticked. It's probably easiest to add them as two separate child objects (50-unit child and 5-unit child). Write a small script that starts the animation in OnTriggerEnter() and assign it to the 50-unit child. Write another that stops it in OnTriggerExit() and assign it to the 5-unit child. Instead of jumping straight into the primary animation, you can create a ramp-up animation that transitions into the primary animation, and similarly for a ramp-down animation.
     
  3. Montraydavis

    Montraydavis

    Joined:
    Aug 28, 2012
    Posts:
    27
    If you check out my 1st person animation thread, it contains a controller which fades between animations using Unity 3D's Mecanim Legacy Controller. Try it out. Also has 40 starter animations (currently).