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);
}
}