jrouwe / JoltPhysics

A multi core friendly rigid body physics and collision detection library. Written in C++. Suitable for games and VR applications. Used by Horizon Forbidden West.
MIT License
6k stars 374 forks source link

Sample CharacterTest.cpp #1139

Closed Snouf-ID closed 1 month ago

Snouf-ID commented 1 month ago

In the sample "CharacterTest.cpp", when the character climbs onto a surface, and you release the movement key, he jumps suddenly. This is not expected behavior. Although it is just a sample, I think that for good practice, we must find a way without this problem.

You can see the bug : https://youtu.be/dTlBwNgZ2Bc

I think this is due to:

        // Update velocity
        Vec3 current_velocity = mCharacter->GetLinearVelocity();
        Vec3 desired_velocity = sCharacterSpeed * movement_direction;
        desired_velocity.SetY(current_velocity.GetY());
        Vec3 new_velocity = 0.75f * current_velocity + 0.25f * desired_velocity;

with SetY

Thank (and thank you for your samples which helps a lot)

jrouwe commented 1 month ago

I fixed the issue. I really recommend looking at CharacterVirtual since it is superior for player movement in almost every aspect.