using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { //the speed of player to move with. public float speed; Rigidbody rbody; Animator anim; // Use this for initialization void Start () { rbody = GetComponent(); anim = GetComponent(); //anim.SetBool("isIdle", true); //anim.SetBool("isWalking", false); } // Physics update, it happens more regularly than the usual Update // Recommended for dealing with rigidbodies. void FixedUpdate() { //This will allows us to move the character using unity default keys (WASD or arrow keys) float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical); rbody.velocity = movement * speed; } // Update is called once per frame void Update () { } }