So, I am working on a fps controller that uses a rigidbody instead of Unity’s Character Controller. I am currently running into a problem where when the player jumps then touches a wall, they will stop moving upward for a second before falling.
I have discovered that the player is still doing their full jump, but won’t go any higher when touching a wall. I also discovered that using Rigidbody.AddForce causes this problem only. Rigidbody.MovePosition won’t. I’m trying to figure out how to do this without using a Physics material on every collidable object in the game
Here is my movement code
private void Update()
{
float v = Input.GetAxis("Vertical") * MoveSpeed;
float h = Input.GetAxis("Horizontal") * StrafeSpeed;
velocity = new Vector3(h, velocity.y, v);
velocity = transform.TransformDirection(velocity);
if (IsGrounded())
{
if (Input.GetKeyDown(KeyCode.Space))
{
RB.AddForce(transform.up * Mathf.Sqrt(JumpModifier * JumpForce * Gravity));
}
}
}
private void FixedUpdate()
{
RB.MovePosition(RB.position + velocity * Time.deltaTime);
}