Unity Runtime - Mecanim

Discuss issues pertaining to the various game/web runtimes of Creature here.
Post Reply
Phaino
Posts: 12
Joined: Mon Apr 02, 2018 5:41 am

Unity Runtime - Mecanim

Post by Phaino » Tue Apr 03, 2018 7:16 am

So I'm trying to get a test character up and running with Creature and Mecanim, but I've run into some issues. I'm having issues with blending animations. I've only been able to find the blend_rate field to modify blending. Are there any options to set blend time? Also, I've tried to set blend time in the transitions, but it doesn't seem to change anything. I have set the do_blending flag on the Creature State Machine Component, but from my understanding of Mecanim, blending options should be defined on the transition and not on the state.

chong
Posts: 1178
Joined: Thu Feb 19, 2015 2:21 am

Re: Unity Runtime - Mecanim

Post by chong » Tue Apr 03, 2018 3:21 pm

Hello,

Creature runtimes are triggered by MecAnim, they do not have full access to internal MecAnim functionality ( because they are not native Unity components )

Blend_rate is basically how quickly it blends to but there is no blend_time option yet ( Blend_rate is basically blend_time, but yes in a more indirect way )

Having said that, if you are not using mesh deform motors or sprite swapping but just bone motors via mesh skinning, you can also export your creature character as a pure FBX file ( export under Images/Video option ). As a FBX model, you have full access to the MecAnim framework in Unity just like any other standard FBX model ( which is why FBX is provided as an export option )

Thanks

Phaino
Posts: 12
Joined: Mon Apr 02, 2018 5:41 am

Re: Unity Runtime - Mecanim

Post by Phaino » Tue Apr 03, 2018 5:13 pm

Thanks! Is there a conversion from blend_time to blend_rate? Is there more documentation on how it's handled?

chong
Posts: 1178
Joined: Thu Feb 19, 2015 2:21 am

Re: Unity Runtime - Mecanim

Post by chong » Tue Apr 03, 2018 8:59 pm

Hello,

Blend_rate just controls a very simple linear blend factor that gets incremented at every animation step. It basically is assigned to the auto_blend_delta variable.
You can see how it is incremented in CreatureModule.cs:

Code: Select all

     
       private void ProcessAutoBlending()
        {
            // process blending factor
            blending_factor += auto_blend_delta;
            if (blending_factor > 1)
            {
                blending_factor = 1;
            }
        }

Phaino
Posts: 12
Joined: Mon Apr 02, 2018 5:41 am

Re: Unity Runtime - Mecanim

Post by Phaino » Wed Apr 04, 2018 3:42 am

Thanks!

Phaino
Posts: 12
Joined: Mon Apr 02, 2018 5:41 am

Re: Unity Runtime - Mecanim

Post by Phaino » Wed Apr 04, 2018 5:07 am

So I added blend time to my local version of the unity runtime. I made ProcessAutoBlending take DeltaTime and multiplied auto_blend_delta by that DeltaTime. You also need to set the blend_rate to the reciprocal of your transition duration. The transition duration can be retrieved from the animator in OnStateEnter.

chong
Posts: 1178
Joined: Thu Feb 19, 2015 2:21 am

Re: Unity Runtime - Mecanim

Post by chong » Wed Apr 04, 2018 3:16 pm

Very nice! That sounds like a good method to convert to Blend times!

Cheers

Post Reply