Animation Actions

Post Reply
User avatar
Kalabasa
Member
Posts: 37
Joined: Tue Jan 06, 2015 17:36
GitHub: Kalabasa
IRC: Kalabasa
In-game: Kalabasa

Animation Actions

by Kalabasa » Post

See Clonk's ActMap for inspiration

Currently, animations are not much flexible. I propose an Action definition for animations. This would make smoother transitions between actions and synchronization of logic with animations.

Actions define a single action in the animation, such as "walk", "jump", and "punch". Actions would be defined in the properties on registering entities.

This is similar to the simplemobs animation framework. But we need more properties for the actions in addition to frame_start, frame_end, and frame_speed. I'm not that good at explaining so I'll post some example code.

Code: Select all

minetest.register_entity("mymod:mymob", {
  -- ...
  actions = { -- An array of actions for this entity
    {
      name = "walk", -- Identifier
      start = 0, -- Start frame
      end = 16, -- End frame
      rate = 30, -- Frame rate
      -- Here's the additional properties of the action
      next_action = "walk", -- The action to be set after this action ends. nil for the old behaviour
      start_call = function, -- Function to call when this action starts
      end_call = function, -- Function to call when this action ends
    },
    -- More action definitions
  }
  -- ...
})

-- To set an animation, instead of set_animation(...), use set_action(action_name)
entity:set_action("walk")
next_action is good for sequencing actions. For example, a jumping sequence:

Code: Select all

...
-- Define actions for jumping
{ -- Jump action
name = "jump",
start = ...,
end = ...,
rate = ...,
next_action = "fall",
},
{ -- Fall action
name = "fall",
start = ...,
end = ...,
rate = ...,
},
...
-- Do the jump
self.object:setvelocity(...)
self.object:set_action("jump")
This makes the "jump" animation play only once, then the "fall" animation is played repeatedly.

start_call and end_call is good for synchronizing logic to animations. For example, a throwing sequence:

Code: Select all

...
{ -- Pick up the rock/Charge the fireball/Whatever pre-throwing animation
name = "prethrow",
start = ..., end = ..., rate = ...,
next_action = "throw" -- After picking up/charging, throw
},
{ -- Throw/Fire
name = "throw",
start = ..., end = ..., rate = ...,
next_action = "stand", -- After throwing, go to idle animation
start_call = throw, -- Fire a projectile
}
...
-- Check enemies to throw at
if player_distance < range then
  self.object:set_action("prethrow")
end
...
-- Throw callback
function throw(self)
  ...
end
...
Another example (death):

Code: Select all

{ -- Define death animation
name = "die",
start = ..., end = ..., rate = ...,
end_call = remove -- Remove the entity after the death animation finishes
}
...
-- Somewhere, maybe in on_punch
if self.object:get_hp() <= 0 then
  -- Start the die animation
  self.object:set_action("die")
end
...
Taking things further

We can take things further, by making the engine automatically set an action for each entity (There could be client-side action prediction too, since the engine decides animations). For example, if an entity is on the ground, the "stand" action is set. When an entity is moving on the ground, "walk" is set. When the entity is off the ground, "fall" is set automatically. This is useful for mobs.

All these can be done in Lua (Yes, even the sequencing and callback part) but they are hacky/dirty.
insert signature here

TG-MyinaWD
Member
Posts: 356
Joined: Thu May 08, 2014 21:22
GitHub: Maddie-Myina
IRC: Maddie-Myina
In-game: .
Location: Far Eden

Re: Animation Actions

by TG-MyinaWD » Post

Look, cool but I never quite understand the whole, Animations thing but this does sound bit more explained.

But only question would be can you have a callback etc if the player was in, a liquid? Since doing some experiment on, the animations to make an swimming animation, still need figure out how put it all flow perfect.
I'm a Transgender no shame about it.
I prefer to be considered as a "Girl/Lady/Miss/Madam/Female" for now on.

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Animation Actions

by Krock » Post

The idea is good.
A maximal speed parameter in "actions" could be useful.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Kalabasa
Member
Posts: 37
Joined: Tue Jan 06, 2015 17:36
GitHub: Kalabasa
IRC: Kalabasa
In-game: Kalabasa

Re: Animation Actions

by Kalabasa » Post

People (uhh, 2 of them (including me)) were complaining on IRC about animations. So, I guess there is demand for an animation improvement.

The main issue I'm addressing here is that animations are always looping. We can't sequence animations.

Example real-world issues:
<ecutruin> wrote:As for animation issues.. imagine opening a chest, and having it re-open continuously.
<Kalabasa> wrote:If I make a jump animation. And play it the moment a mob jumps, the animation will repeat in midair.
Will look like double jumping
SuperTuxKart, which uses irrlicht, doesn't have repeating animations. Maybe we can copy some of their code. STK is not networked though.
insert signature here

wilkgr76
Member
Posts: 832
Joined: Wed Feb 18, 2015 02:44
GitHub: wilkgr76

Re: Animation Actions

by wilkgr76 » Post

Kalabasa wrote:SuperTuxKart, which uses irrlicht, doesn't have repeating animations. Maybe we can copy some of their code. STK is not networked though.
I believe the animations are rendered locally, which is to say, the client decides which animations to play. STK multiplayer is coming soon, I think.
N/A

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests