Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Help with playing animations

Discussion in 'Scripting' started by wilhelmscream, Jun 17, 2014.

  1. wilhelmscream

    wilhelmscream

    Joined:
    Jun 5, 2013
    Posts:
    223
    After working a couple of tutorials I'm not certain what I'm doing wrong here. The animation I'm trying to run is fairly basic (a simple extension of object A and rotation of child object B). Here's the code I'm using:

    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var myTarget : Transform;
    4. var launchPosition : Animation;
    5. var launchReady = false;
    6.  
    7. function Start () {
    8. }
    9.  
    10. function Update() {
    11. }
    12.  
    13. function OnTriggerStay (other : Collider) {
    14.     if (other.gameObject.tag == "EnemyArmor") {
    15.         myTarget = other.gameObject.transform;
    16.         launchReady = true;
    17.         LaunchElevate ();
    18.     }
    19. }
    20.  
    21. function LaunchElevate () {
    22.     launchPosition.Play ();  
    23. }
    Here's what the inspector looks like:

    Screen3.png

    And the animation import screen:

    Screen2.png


    Anyone see the obvious mistake I'm making? Any help or suggestion is appreciated.
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,738
    Look under 'Rig'. Is it importing as Generic, Humanoid, or Legacy?

    There are two animation systems in Unity:

    Mecanim: Uses "Generic" or "Humanoid" settings, and the Animator component.

    Legacy: Uses the "Legacy" setting, and the Animation component.

    Hope this helps.
     
  3. wilhelmscream

    wilhelmscream

    Joined:
    Jun 5, 2013
    Posts:
    223
    It was set for "Generic". Switched to "Legacy" (btw, is there a significant advantage to Mecanim?).

    Now it rotates the whole model 90 degrees, and plays (can't tell) either the default take or both of the other two..... without waiting for the trigger. I unchecked "Play Automatically" with no result.
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,738
    Once you learn to use its workflow, it has a lot of convenience in most scenarios. It's FANTASTIC for characters, where it supports complex behavior trees/webs/flows and blend trees (for blending smoothly between different speeds of walk/run animations, for example). Even better for humanoid characters, where it supports IK, automatic head-turning/looking, etc.
     
  5. wilhelmscream

    wilhelmscream

    Joined:
    Jun 5, 2013
    Posts:
    223
    Ok. Probably need that once I get into infantry but seems excessive for a simple missile launcher, no?
     
  6. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,738
    It's just a matter of getting used to the workflow, not so much a matter of "overkill" or not. I use it pretty much everywhere in my projects these days.
     
  7. wilhelmscream

    wilhelmscream

    Joined:
    Jun 5, 2013
    Posts:
    223
    I'll figure it out eventually. Meantime I still don't see a solution here.
     
  8. wilhelmscream

    wilhelmscream

    Joined:
    Jun 5, 2013
    Posts:
    223
    Any thoughts?