Mina Fawzy
Mina Fawzy

Reputation: 21452

Unity - move animated game object with rigidbody.velocity

I have an animated character , and I need move it forward

I add rigibody to my character , and mover class

when I disable animated controller it moves

my mover class

 using UnityEngine;
    using System.Collections;

    public class Mover : MonoBehaviour {


        public float speed;
        // Use this for initialization
        void Start () {
            GetComponent<Rigidbody>().velocity = transform.forward * speed;

        }


    }

any suggestion how I can approach that

enter image description here

Upvotes: 0

Views: 4389

Answers (2)

maraaaaaaaa
maraaaaaaaa

Reputation: 8193

Might want to put it in Update() so its not just called one time.

void Update () {
    GetComponent<Rigidbody>().velocity = transform.forward * speed * Time.smoothDeltaTime;
}

Upvotes: 0

Mina Fawzy
Mina Fawzy

Reputation: 21452

I find out the answer

just uncheck Apply Root Motion

enter image description here

Upvotes: 3

Related Questions