Can you please help me to uderstand the concept here correctly: Is the humanoid rig meant to be used only with characters that are translated by script or root motion?
To clarify what I am looking for: We usually have game scenes where characters have to interact with props in a rigid set. So for example we have a room with a lever and a laptop on a desk with a chair. A character sits on the chair, working on his laptop and waits for an interaction. On trigger he stands up, walks over to the lever, pulls it and then respawns sitting in front of the desk.
Basically we use this with generic animation and just let it play. Now it would be cool if we were able to use Mecanim to recycle or repurpose certain animations. The problem here is that Mecanim seems to be using only root motion or keeping the character frozen in place waiting for a translation to happen by script or any other external manipulation.
Problem here being that root motion can introduce minor inconsistencies with placement that can add up to major ones if played too many times.
So is there a way to move a character by animation without actually applying root motion but still benefiting from Mecanim?
Yes - a lot of teams use code driven locomotion with all the benefits of mecanim. Mecanim is not exclusive to root motion.
With that said - the description you provided seems like it is set up to use root motion, and you would benefit from using it. The reasons you would benefit is because all the interactions you described are ‘set movements and set distances’.
Root motion is great for people who prefer to control the locomotion in the animation rather than having to program the locomotion.
Certain games that require a high fidelity in the animation with a requirement that foot slippage is not acceptable like a close up 3rd person game or games that have the character on screen all the time, usually choose root motion for accurate animation display. No coder will be able to create locomotion as well as an animator who specializes in creating believable or convincing animations. With that said the best character set ups are the ones where a programmer and an animator work together to set up the character with the best set up for that specific game.
In addition to using root motion or not - some setups provide non-root motion and root motion combined in the same motion flow.
Usually this setup is used when the game is designed to drive the character by code - but certain motions like wall climbing, climbing ladders, interacting with elements in the scene - like a desk or chair, perform better when root motion is used. So during these animations root motion will take over from coded locomotion to provide the best visual fidelity for these types of motions.
If you feel more comfortable driving the character with code you can set up the character to move with code and then when he has to interact with objects - allow the animations to drive the character with root motion, however the examples provided, (interacting with a lever and laptop) don’t really call for root motion to be used. You can still use root motion to move the character into the exact place you need him to be in order to interact with those objects - but this seems like it could also be done with code without much headache.
Hope this helps - clarify some of the ways a character controller and mecanim is used in general. I’m a animator so I can only speak as a non-coding artist.
We usually script as few things in the scene as possible and our animation pipeline currently is to animate a rigied scene with specific animations to the scene setup. Pretty close to an animated movie in that regard. While I would love to do it in a more dynamic and/or code driven way this is at the current point not an option.
I will definately look into the things you proposed for future projects, though.
What I am currently looking for is more or less whether Mecanim is able to play an animation in the same way the generic setup currently does without root motion: Play an animation file the way it is without either actually moving the character or keeping it in place to wait for a translation by code. A mere playing of the animation if that makes sense?
We surely can just use generic setup for the task as well but I am asking because Mecanim obviously still has benefits that generic doesn’t offer even if not used to the full capacity it was intended for.
Generic is part of mecanim. I think you are thinking either generic or humanoid rather than generic or mecanim.
Both generic and humanoid can use root motion or code driven locomotion. The main difference is generic is not limited to the humanoid retargetable rig. Humanoid provides retargeting on the humanoid rig. Humanoid includes built in IK and provides a mirroring function for animations.
Those are the main (only) differences between humanoid and generic rig setup in mecanim.
One other element you might want to research is match.target. I am unfamiliar with this programmer technique, but it sounds like it might be beneficial to you in your project.
The thing with humanoid animation is that I can either apply root motion to drive the relative position of the character or drive the position by code. I cannot drive the absolute position by animation any more, though. That seems to be only able with generic animation.
Take an animation where the character walks a straight line. With humanoid there are two posibilities:
The character is driven by root motion and keeps on walking forever.
The character is driven by code/logic and walks in place, only.
With generic I could have the animation match and loop the way it is set up in the animation. Meaning - it would reflect the same way it is being seen in the Maya viewport. The character moves and as soon as the animation starts again the character is set back to the start of the animation again.
That is the behaviour I have to mimic in the current project.
And so far this seems to be doable with generic only, correct?
No - I’m sorry but I did not understand your explanation above.
Both generic and humanoid rig can both be code driven or root motion driven. Both can loop an animation cycle and it be seamless. Both can have animation blends and both can have mixed locomotion.
I think the dilemma you are having is the setup with a humanoid model that does not use root motion? The documentation and animation section provides instruction on how to use humanoid rig and not use root motion.
You can disable root motion any time in code, and turn it back on. Works well done it lots.
Also, what I sometimes to is apply a bit of force to a root motion controlled character. Just for a moment, during part of an animation or state or something.
Can dig out the one-liners to do this if you like. Script docs are good though