- Home /
in place motion problem.
Hello Guys ,
I am going through the following code for the in place animation movement .
using UnityEngine; using System.Collections;
[RequireComponent(typeof(Animator))]
public class RootMotionScript : MonoBehaviour {
void OnAnimatorMove()
{
Animator animator = GetComponent<Animator>();
if (animator)
{
Vector3 newPosition = transform.position;
**newPosition.z += animator.GetFloat("Runspeed") * Time.deltaTime;**
transform.position = newPosition;
}
}
}
the line where newposition is updated we access the curve value(Runspeed) . But as the animation is looping so the value must also loop . So , how we will get constant speed .
You must click EDIT and use a short question title about your question. (even "animation problem" would be O$$anonymous$$).
otherwise the question will be deleted by moderators
Your answer
Follow this Question
Related Questions
position change due to animation 1 Answer
Why isn't mecanim not playing root motion is anim compression is off? 0 Answers
How does the Animator drive Rigidbody with root motion (in detail)? 1 Answer
Mecanim "turnonspot" with mouse and not WASD 1 Answer
Issues with camera and movement stutter on root motion driven looping animations 1 Answer