Search Unity

Screwing in any order before Covering

Discussion in 'Animation' started by mLuby, Jan 19, 2020.

  1. mLuby

    mLuby

    Joined:
    May 26, 2014
    Posts:
    2
    Hi, I'm an experienced web dev but just learning Unity. I researched this specific problem for days, reading the docs, forums, blogs, and watching YouTube tutorials, but I can't find anything close enough to help me, so I'm hoping you fine folks can get me unstuck!

    I've got the following simple scene (but I want to be able to easily add more screws later).
    • machine_housing
      • left_screw
      • right_screw
      • (potentially more screws)
      • cover_plate

    I want to be able to
    1. unscrew left_screw then right_screw then remove cover_plate
    2. OR unscrew right_screw then left_screw then remove cover_plate.
    More generally, I want to be able to unscrew in any order, but only uncover once all are unscrewed. (And of course, reverse the process.)

    Is there a way to do this using animation controller(s) and state machines? I've been trying to avoid writing animation code in scripts, but maybe that's unavoidable in this case.

    I currently have an Unscrewing animation in a Screw animation controller that each screw model uses and an Uncovering animation in a Plate controller attached to the plate model. They both look like this (s/cover/screw):


    Ideas:
    1. I could delete these controllers and create the animation controller on the parent machine_housing that could control each child, but I can't figure out how to do the "in any order" part without a factorially-increasing number of transitions, or only being able to unscrew/uncover, not cover/re-screw.
    2. If I could access each screw's "attached" boolean parameter in the transition to Uncovering state, that would work, but I don't think that's allowed.
    What do you recommend? Thanks in advance!