Search Unity

Can't get/set Animation time or frame in script

Discussion in '2D' started by Shnayke, Dec 22, 2013.

  1. Shnayke

    Shnayke

    Joined:
    Mar 29, 2013
    Posts:
    11
    Hi All - I can't seem to properly get/set the frame of animation for a projectile I'm shooting:

    When I try to reference anim.playbackTime , I get a notification that I need to StartPlayback(). If I Startplayback in the script though.. my collision detection gets killed :(.

    Also, I just noticed that the primary animation for my bullet never progresses past the first frame, and I have no idea why.

    (In gameplay mode, just aim and click with mouse to shoot)

    Bullet location: pistol_bullet in Prefabs folder
    StraightProjectileMovement.cs is the script

    Alternatively, I'd like to get a trigger to see when I can see the end of an animation, rather than simply having to manually check for the frame number itself. I.e. "When explosion animation is done, then Destroy the gameobject"

    Project:
    https://www.dropbox.com/sh/gr9aqmfvky2sjes/WXoXmT_brd

    Scene:
    https://www.dropbox.com/s/4tivoan77t1u8fj/F***Everything.unity.meta

    Any help appreciated, and please excuse any saltiness you may find in the code/assets :(
     
  2. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794
    Hi there,

    I've made a quick youtube explaining some of the places you've gone wrong, its just uploading but im on mobile wifi connection, so will be a little while. Will post link when its up,

    Cheers

    Will
     
  3. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    794