Unity animation running, and then just teleporting the player back to origin
Im using a blend tree for movement with a value of inputH and inputV when the user presses a button. The main issue Im having is that my player teleports back to the point of origin as soon as they finish the walking animations.
link:This is what the tree looks like
Is there a way to fix this?
using UnityEngine; using System.Collections;
public class player : MonoBehaviour {
public Animator anim;
private float inputH;
private float inputV;
public Rigidbody rbody;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
rbody = GetComponent<Rigidbody> ();
}
// Update is called once per frame
void Update () {
inputH = Input.GetAxis ("Horizontal");
inputV = Input.GetAxis ("Vertical");
anim.SetFloat ("inputH", inputH);
anim.SetFloat ("inputV", inputV);
float moveX = inputH * 20f * Time.deltaTime;
float moveZ = inputV * 50f * Time.deltaTime;
rbody.velocity = new Vector3 (moveX, 0f, moveZ);
}
}
Comment