Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | smudgecat123 |
I am working on a 3D game and I want my player character to respond to forces so I need to use a Rigidbody
but I also want them to have snappy near-instantaneous horizontal movement, like a KinematicBody
.
I’m really struggling to figure out how to have both of these simultaneously.
Ideally, player movement would be represented by a constant offset on the linear velocity of the Rigidbody
but it seems this is not really possible from looking at the Rigidbody
API.
I have attempted to cleverly apply impulses per physics frame (in _integrate_forces
) in order to apply movement in a given direction (whilst simultaneously undoing the movement from the previous frame). But this has become very complex in circumstances where other forces and/or collision stop or redirect the velocity applied by that previous movement. I’ve also tried simply offsetting the position of the Rigidbody
each frame depending on the intended movement direction but this leads to the physics engine not recognizing the change in linear velocity and issues with collision detection.
Is there a standard solution for this? It seems like it would be a common requirement for a lot of 3D games. Thanks.