#Animation controllers

13 messages · Page 1 of 1 (latest)

cloud pulsar
#

How would you recommend creating an animation controller for an entity that just walks around and attacks the nearest player? (One animation for walk, another for attack)

mental oasis
#

It depends on a multitde of factors.

If you are using a normal melee attack behavior, you would likely want the walking and attacking animations to be in separate controllers. The mob would continue to move and pathfind while it performs melee attacks, and if you had a walking state and an attacking state in a single controller then the mob would stop playing its walk animation to perform the attack animation.

#

Whether you need controllers at all depends on how the animations are built too. For keyframed animations a controller would work best—purely Molang animations probably don't need controllers.

cloud pulsar
cloud pulsar
mental oasis
#

Sorry for the delay with responding.

#

All mobs have a built-in variable that records how long they have been attacking for, named variable.attack_time. You can use this to play an attacking animation when the mob attacks

#

Here is an example of what that might look like:

{
  "controller.animation.mob_attack": {
    "states": {
      "default": {
        "transitions": [
          {
            "attack": "variable.attack_time > 0"
          }
        ]
      },
      "attack": {
        "animations": [
          "attacking"
        ],
        "transitions": [
          {
            "default": "variable.attack_time == 0 && query.all_animations_finished"
          }
        ]
      }
    }
  }
}
#

@cloud pulsar

#

If you are wanting only one to be played at a time and not combine, you can throw the walking animation into the default state

cloud pulsar
#

I’ll try this when I can get back to a computer

cloud pulsar
mental oasis
#

yes