Hello, There is my problem ,I wrote a script to move my character, i can jump if i go in straight direction but in diagonal my character doesn’t want, except with arrow keys up+right.
void FixedUpdate() { jump();
Vector3 camForward = cam.forward;
Vector3 camRight = cam.right;
float moveHorizontal = Input.GetAxisRaw("Horizontal");
float moveVertical = Input.GetAxisRaw("Vertical");
Vector3 movement = (moveHorizontal * camRight + moveVertical * camForward); //new Vector3(moveHorizontal, 0.0f, moveVertical);
movement = movement.normalized * Time.deltaTime * speed;
if (movement != Vector3.zero)
{
Debug.Log("I walk");
isMoving = true;
if (isGrounded) {
transform.Translate(movement, Space.World);
}
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(movement.normalized), 0.2f);
if (isGrounded == false )
{
Vector3 gravite = new Vector3(0.0f, -0.01f - (vitesseAcceleration), 0.0f);
transform.Translate(movement + gravite , Space.World);
Debug.Log("WALKKK");
vitesseAcceleration += 0.01f;
}
}
}
}
Jump does a raycasting to check if is grounded but it works, i thought it could be a problem with rigidbody because i used rigidbody.addForce(jumpForce, Force.Impulse); but now i use only translation on my transform but the problem remains. All works, jump in any direction just if i move in diagonal like arrow keys : Up+ Left Bottom+Left and Bottom+right Maybe because of one of input ,i honestly have no clue