Easy property to make animation blending

Posted on

DefaultAnimationTransition in CGE editor

We introduced TCastleSceneCore.DefaultAnimationTransition property.

This is a really easy way to request animation cross-fading (blending) which makes changing animations look much smoother. Just set this to some non-zero value to have smooth animation change. It’s the time in seconds, often it’s reasonable to start with something small like 0.1.

This is also configurable in the CGE editor (as it’s a published property). Our “New Project” template 2d_game is using it.

And it’s available in resource.xml file for the creature. Our examples/fps_game/ is using it for the “knight” creature. Like this:

<model url="knight.gltf" pool="10" default_animation_transition="0.25">
  <idle   animation_name="Idle"    />
  <walk   animation_name="Walk"    />
  <attack animation_name="Attack"  />
  <die    animation_name="Die"     />
  <hurt   animation_name="Damaged" />
</model>

This also brings improved switching to the default state (like idle or walk) after Attack/Hurt. This makes animation change smoother for creatures using resource.xml, whether you use default_animation_transition or not.

Notable Replies

  1. What can we do if we use different model for every animation?

  2. What can we do if we use different model for every animation?

    I’m afraid that animation blending cannot work when a different model is used for different animation. There’s no way to perform animation blending between 2 arbitrary models.

Continue the discussion at Castle Game Engine Forum

Participants

Avatar for RamazanGeven Avatar for michalis