I have this basic script in my game for navigating my character around a top down level, but every time I press any of the keys, there's a slight input lag and the screen freezes for just a second.
I'm not sure how to fix it. If anyone had any ideas, I'd appreciate it.
var walkSpeed: float = 7.0;
function Start () {
}
function Update () {
rigidbody.freezeRotation = true;
if(Input.GetKey("w")) transform.Translate(Vector3(0, 0, 1) * Time.deltaTime * walkSpeed);
if(Input.GetKey("s")) transform.Translate(Vector3(0, 0, -1) * Time.deltaTime * walkSpeed);
if(Input.GetKey("a")) transform.Translate(Vector3(-1, 0, 0) * Time.deltaTime * walkSpeed);
if(Input.GetKey("d")) transform.Translate(Vector3(1, 0, 0) * Time.deltaTime * walkSpeed);
}
I would suggest using the character controller that comes with the standard assets. It takes care off all fps movements out of the box.