Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Animation Controller and persistent state/entry? (Treasure Chest)

Discussion in 'Animation' started by KungFooMasta, Oct 24, 2017.

  1. KungFooMasta

    KungFooMasta

    Joined:
    May 27, 2014
    Posts:
    24
    I've been searching online but I can't find a good answer how people do this. I have a treasure chest with animations to open and close. Couple problems:

    1. If I set the Entry animation state to Closed, when the scene loads the treasure chest plays the Closed animation. (Treasure chest teleports open and lid closes down over time) What is the right starting animation state? I created another animation called Closed from frame 0 to 0 and set it as the starting state.. it seems to work but..

    2. How to implement persistence, for example loading a scene should show an already opened chest since it was previously opened? It seems like I need to be able to either start in the closed state or the opened state, and not run any animations during this state, and I'm not sure how to represent this in the controller. What do other people do? I looked up some thread about multiple entry transitions but no clear solutions.
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    You need an idle state - closed with no animation - or 1 frame animation without the lid moving.

    Persistence is loaded - so the state needs to be saved. I use playmaker so I can't tell you how to do this with code. Might look into player prefs ?? but I'm not sure if that is for entire scene states or only player settings and such.
     
  3. KungFooMasta

    KungFooMasta

    Joined:
    May 27, 2014
    Posts:
    24
    Thanks, I think I figured it out with your advice. I have a empty state that is my starting state, labelled "WaitingForInput", and I will need to have a script that sets the "IsClosed" trigger or the "IsOpened" trigger. Once in one of those states, the chest can be opened and closed as usual. (5 states total: WaitingForInput, Closed, Opened, Open, Close)
     
    theANMATOR2b likes this.