My character will not jump at all. I have tried many solutions but to no avail. (this is 3D)
How to I fix this?
I have tried using RigidBody gravity and the Rigidbody.AddForce but it does not work either.
void Update()
{
Vector3 velocity = Vector3.zero;
if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("jumping");
velocity.y = _jumpForce;
}
else
{
// Apply gravity
velocity.y -= _gravity;
}
// Move the controller
_controller.Move(velocity * Time.deltaTime);
}
This works for other people but not for me. I have an attached CharacterController.
,After trying many solutions, I am not able to make my character jump. I had simplified my code, and tried to debug the issue but to no avail. The script also logs “jumping”, showing that it iterates through the section where the jump code is.
// Update is called once per frame
void Update()
{
Vector3 velocity = Vector3.zero;
if (Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("jumping");
velocity.y = _jumpForce;
}
else
{
// Apply gravity
velocity.y -= _gravity;
}
// Move the controller
_controller.Move(velocity * Time.deltaTime);
This is someone else’s code that seems to work, but not for me.
I tried using the RigidBody gravity system and using rb.AddForce but that doesnt work either.
Even after removing the rigidbody component, I am still unable to jump.
I have a CharacterController Attached.