With this script my player when i start the game move aouto matically forward and when i press the w,a,s,d nothing happen …
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Moving : MonoBehaviour {
public Animator anim;
public Rigidbody Rbody;
private float InputH;
private float InputV;
void Start () {
InputV = Input.GetAxis ("Vertical");
InputH = Input.GetAxis ("Horizontal");
anim.SetFloat ("InputH", InputH);
anim.SetFloat ("InputV", InputV);
anim = GetComponent<Animator> ();
Rbody = GetComponent<Rigidbody> ();
float moveX = InputH * 20f * Time.deltaTime;
float moveZ = InputV * 50f * Time.deltaTime;
Rbody.velocity = new Vector3 (moveX, 0, speed);
}
void Update () {
if (InputV != 0) {
anim.SetBool ("Move", true);
} else {
anim.SetBool ("Move", false);
}
}