- Home /
Mixing root motion animation and in place animation
So as far as I understand you use root-motion to actually move your object with animation, correct me if I am wrong. So I want to use it for cutscenes, but later on I want to use the same object for normal gameplay with root motion beeing switched of. But my character doesn't move and animator says "Root position or rotation are controlled by curves".
So how would you go about this? Perhaps I am doing something completly wrong but my actual goal is being able to move character with animation when it's needed and by coding when needed.
UPD ------------
So I will update my question a bit, because I still don't understand. I am providing code for the object and coresponding animator controller. As you can see NewState is just an empty state. cs_theBeginning_brother is the actual cutscene. It's not connected to anything so as I thought it would not have any effect on the object whatsoever. If I delit it everething works fine(object is moving). The really odd thing for me is that when cs_theBeginning_brother is added to the animator controller the object doesn't move whith root motion being switch off, but it does move with activated root motion. Code is the same in all three scenarios. Sorry I know thats a lot of stuff but I am really confused so I will apreciate any help on this.

private void Start()
{
rb = GetComponent<Rigidbody2D>();
}
private void FixedUpdate()
{
rb.velocity = new Vector2(2, 0);
}
Answer by meat5000 · Jan 17, 2018 at 02:00 PM
Root Motion is best achieved by actually manually moving the model per keyframe in your external 3D modeller. You can then switch root-motion off and perform the animations in-place. Curves can be created or adjusted from within Unity's own animation window.
Thank you for clarification with root motion. But I still don't understand how to move my object, with root motion being switched off I get this message "Root position or rotation are controlled by curves" as you can see on screenshot. So I can't move it, how to solve this?
That's not an error, its a statement :) Its telling you its under the control of the curves. Perhaps set up some curves?
Root motion is entirely optional. Here is the old tut on Root-$$anonymous$$oving an In-place animation
https://docs.unity3d.com/$$anonymous$$anual/ScriptingRoot$$anonymous$$otion.html
If your model HAS Root-$$anonymous$$otion but you want it to be in place, click on the Prefab/Imported file for your object. In the Inspector's Import -> Animation section you can see three Boxes that will prevent the movement of animations in certain ways.
Answer by Dray · Jan 17, 2018 at 08:04 PM
Forget about the curves for a moment, what you need is a custom script that moves your player when needed. Something like this:
void Update() {
if (rootMotionIsDisabledAndImMovingForward) {
transform.position += transform.forward * speed * Time.deltaTime;
}
}
or if you are using physics:
void FixedUpdate() {
if (rootMotionIsDisabledAndImMovingForward) {
rigidbody.MovePosition(transform.position + transform.forward * Time.fixedDeltaTime);
}
}
you could also use the rigidbodys velocity or even control the velocity using one of these magical AnimatorCurves you mentioned but maybe a simple approach as above suits your needs allready
Your answer