Search Unity

Animations not Playing in Old Textbook Tutorial Project

Discussion in 'Animation' started by TimHeard, Jul 3, 2018.

  1. TimHeard

    TimHeard

    Joined:
    Jul 27, 2016
    Posts:
    1
    I was following along a textbook titled Beginning 3D Game Development with Unity 4 by Sue Blackman when I hit a snag. While that book may have covered an obsolete version of Unity, I'm convinced that most of the methods described in that book still hold up and can be carried over to Unity 5. I had reached the early pages of Chapter 8 titled Action Objects when I encountered a problem. I cannot get the animations to play in Play mode even though I followed along the instructions to the letter (for the most part). The models I was using for the tutorial project were the downloadable ones used for the book:

    2018-07-02.png

    In following the instructions for triggering animation, I attempted to get the following to play animations:

    2018-07-02_23h45_58.png

    First, I wrote a script that the book called AniTest:

    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var aniParent : GameObject;
    4. var aniClip : AnimationClip;
    5.  
    6. function OnMouseDown () {
    7.     print(name + " picked using " + aniClip.name);
    8.     aniParent.GetComponent.<Animation>().Play(aniClip.name);
    9. }
    Then added the AniTest script to the Rock and ChestLid and made sure that the appropriate animation clips were assigned and the AnimationObjects group was assigned as the Ani Parent:

    2018-07-02_23h45_29.png 2018-07-02_23h45_44.png

    Yet, the animations never played during my play tests. I attempted to make a few adjustments to the AniTest script to no avail. I am seeking advice as to how to get the test animations to play whenever I click the mouse button on the test objects.
     

    Attached Files: