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

Change animation randomly using script (around 4 animations)

Discussion in 'Animation' started by Amirh18, Jun 9, 2017.

  1. Amirh18

    Amirh18

    Joined:
    Mar 28, 2016
    Posts:
    16
    Hi, I wonder how this process will go
    How easy it is to create an array of around 5 idles animations and change them randomly.
    Like when one finishes another random one starts and this process happnes all the time.
    I know that there is an animator for that but I am looking to do it only using script.
    Thanks
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Idk how in script but the mecanim way is to use sub-state machines.
    Might lead to what you want if you look into sub-states in the documentation.
     
  3. TrickyHandz

    TrickyHandz

    Joined:
    Jul 23, 2010
    Posts:
    196
    This is a great talk from a couple years ago. David Geoffrey opens up with a demo of randomizing a melee animation. The principle is the same for randomizing an idle animation using StateMachineBehaviours

    Cheers,
    TrickyHandz