What is wrong with this why can't i move?
using UnityEngine; using System.Collections;
public class PlayerMovement : MonoBehaviour { public float speed; private Rigidbody rbody;
// Use this for initialization
void Start () {
rbody = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update () {
float inputX = Input.GetAxis("Horizontal");
float inputZ = Input.GetAxis("Vertical");
float moveX = inputX*speed*Time.deltaTime;
float moveZ = inputZ*speed*Time.deltaTime;
rbody.AddForce(moveX, 0f, moveZ);
}
}
Comment
using UnityEngine; using System.Collections;
public class Player$$anonymous$$ovement : $$anonymous$$onoBehaviour { public float speed; private Rigidbody rbody;
// Use this for initialization
void Start ()
{
rbody = GetComponent<Rigidbody> ();
}
// Update is called once per frame
void Update ()
{
float inputX = Input.GetAxis ("Horizontal");
float inputZ = Input.GetAxis ("Vertical");
float moveX = inputX * speed * Time.deltaTime;
float moveZ = inputZ * speed * Time.deltaTime;
//transform.Translate(moveX, 0f, moveZ);
rbody.AddForce (moveX, 0f, moveZ);
}
}