- Home /
Can't jump in diagonal
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
Answer by zeropointblack · Jun 21, 2020 at 01:01 PM
this one too. me as well. same deal. what gives? seems not too many people are running into this issue. hmm....
Your answer
Follow this Question
Related Questions
How to keep ball from jumping more than once? 1 Answer
Problem with jump bool. Help?! 0 Answers
Get the character jumps in his local position 0 Answers
Booleans are not working 1 Answer
Dynamic jump? 1 Answer