How to control step distance for root motion (Mecanim) animations?

I have become quite comfortable with the legacy animation system and will now be making my first attempt at the mecanim way of doing things.

One of my first issues while using root motion is getting a consistent step distance or overall movement speed for characters of different scales. For example, the player avatar will have slightly customizable size (scale). Also the enemy characters will have a script attached which will randomly choose a size (within a range), so that all of the enemies are not the exact same size by default. With root motion however, the larger characters have a larger step distance and therefore move faster than the smaller ones.

I would like to be able to control this, similar to how in the legacy system you can set a specific speed. For example, if I need all characters irrespective of size to move at the same speed, or the larger characters may need to move slower than the smaller ones since they are more heavy.

Apart from changing the animation speed, is there a setting in the animation properties or a way to do this via script in mecanim?

2 Answers

2

If your problem appears after resizing the objects:
You should add your original gameObjects(Avatar,…) as a child of an empty game object. Then change the size of the parent gameObject. In this way everything should work fine.

I am not quite sure how parenting a character to an empty should change the distance of each character's walk step, or the overall walk speed. I have tried what you suggested and it makes no difference as far as I can see. Could you please explain this some more.

Based on my research it looks like that the only way to do the above at the moment is to set the specific animation to loop in place, and then override the root motion via script. This can also be used for other distance based animations such as jumps, dodges etc in which you need precise control over the distance traveled, or if this distance needs to change at runtime (based on stats for example). Here is the link to the documentation that covers this: Unity - Manual: Tutorial: Scripting Root Motion for "in-place" humanoid animations

Mono.Data.Sqlite.SqliteException: SQLite error no such table: Account at Mono.Data.Sqlite.SQLite3.Prepare (Mono.Data.Sqlite.SqliteConnection cnn, System.String strSql, Mono.Data.Sqlite.SqliteStatement previous, UInt32 timeoutMS, System.String& strRemain) [0x00000] in :0 at Mono.Data.Sqlite.SqliteCommand.BuildNextCommand () [0x00000] in :0 it work at editor not in android..pls help