# Diagonal movement faster speed help plz

I know the function VectorLength but I dont know where to apply it in this code, can someone help me?

``````public class CC : MonoBehaviour
{

public float walkSpeed = 6.0f;
public float runSpeed = 12.0f;
public float jumpSpeed = 8.0f;
public float gravity = 20.0f;

public CharacterController cc;
private Vector3 move = Vector3.zero;

public Camera cam;
public float mouseH = 3.0f;
public float mouseV = 2.0f;
public float minRot = -65.0f;
public float maxRot = 60.0f;

float h_mouse, v_mouse;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}

// Update is called once per frame
void Update()
{
h_mouse = mouseH * Input.GetAxis("Mouse X");
v_mouse += mouseV * Input.GetAxis("Mouse Y");

v_mouse = Mathf.Clamp(v_mouse, minRot, maxRot);

cam.transform.localEulerAngles = new Vector3(-v_mouse, 0, 0);
transform.Rotate(0, h_mouse, 0);

if (cc.isGrounded)
{
move = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical"));

if (Input.GetKey(KeyCode.LeftShift))
{
move = transform.TransformDirection(move) * runSpeed;
} else
{
move = transform.TransformDirection(move) * walkSpeed;
}

if (Input.GetKey(KeyCode.Space))
{
move.y = jumpSpeed;
}
}
move.y -= gravity * Time.deltaTime;

cc.Move(move * Time.deltaTime);
}
}
``````

Row 40:
You get direction based on user input. When no keys down you get length of 0 for your direction vector. When one key down you get length of one - sqrt(1). Two keys down - you get lenght of sqrt(2)
You need to Clamp length of your vector to one and in you cases you will get such a result:
No keys down - length is 0
Any key down - length is 1

Docs for solution:

Solution:
Change code on row 40 to this:

move = new Vector3(Input.GetAxis(“Horizontal”), 0.0f, Input.GetAxis(“Vertical”));
move = Vector3.ClampMagnitude(move);