How can i change my movement for mobile i think left and right gonna work but i don't know what should i do for jump
private void Update()
{
vector = Vector3.zero;
if (characterController.isGrounded)
{
/*verticalVelocity = -gravity * Time.deltaTime*/;
verticalVelocity = -0.5f;
if (Input.GetKeyDown(KeyCode.V))
{
verticalVelocity = jump;
}
}
else
{
verticalVelocity -= gravity * Time.deltaTime;
}
vector.x = Input.GetAxisRaw("Horizontal") * speed;
if (Input.GetMouseButton(0))
{
if (Input.mousePosition.x > Screen.width / 2)
vector.x = speed;
else
vector.x = -speed;
}
vector.y = verticalVelocity;
vector.z = speed;
characterController.Move(vector * Time.deltaTime);
}
I solved the problem this way
if (characterController.isGrounded)
{
verticalVelocity = -0.5f;
if (Input.GetMouseButton(0))
{
if (Input.mousePosition.y > Screen.height / 2)
{
verticalVelocity = jump;
}
else
{
verticalVelocity = -jump;
}
}
}
else
{
verticalVelocity -= gravity * Time.deltaTime;
}
vector.x = Input.GetAxisRaw("Horizontal") * speed;
if (Input.GetMouseButton(0))
{
if(Input.mousePosition.y < Screen.height / 2)
{
if (Input.mousePosition.x > Screen.width / 2)
vector.x = speed;
else
{
vector.x = -speed;
}
}
}