Hello,
I made a 2D Jump’n’run but have a little problem:
When the player jumps against a other solid cube collider (like a invisible wall - the border for the level - or the side of a platform) it just stays in the air as long as the player keeps moving in that direction.
I use the standard gravity from unity and this is the movement script:
rigidbody.velocity = new Vector3(moveSpeed * Input.GetAxis(“Horizontal”), rigidbody.velocity.y, rigidbody.velocity.z);
I directly set the velocity instead of using AddForce because the latter of whom doesn’t work that well when using standard gravity in 2D (the player sprite -cube collider- slows down hardly on the ground -more cube collider- while the player is to fast in the air).
The problem is that the horizontal collision between those colliders slows down the vertical velocity.
I tried to use rigidbody.velocity = new Vector3… when the player horizontally collides with a wall but that doesn’t fit because it isn’t as smooth as the natural gravity.
Does anyone have another idea to solve this?