[SOLVED] Dynamic Character Controller doubt
Posted: Sat Jun 27, 2020 8:14 pm
Hello,
I am trying to use a dynamic (non-kinematic) character controller for my game, using the capsule shape as the collision shape.
It is working great, except for one case that I am not able to find a good solution so far.
When standing a tiny bit over an edge, the contact point between the ground and the bottom of the capsule shape is no longer perfectly centered in the middle of the capsule shape. In this scenario, if I induce a rotation (either by adding torque or adding angular speed), the capsule not only rotates, but also translates laterally.
I understand that this is the correct physics behavior, but I need to override it, because as much as it is dynamically correct (given the capsule shape and how friction/center of mass works), it is terrible for the character control.
Right now I am casting rays to check if the character is on an edge, and then reposition the rigid body on the desired position, instead of letting the physics control the rotation. This way I can force the capsule shape to "stay put" on the same place and avoid the unwanted translation.
This still feels wrong, as it induces a different behavior when rotating while walking a little bit past an edge, as the repositioning of the rigid body cancels any other movement components that were also applying forces to the body.
For example, when the character is walking on a flat surface, and I induce a rotation, the character naturally keeps moving forward while at the same time rotating. This is the correct behavior that feels very natural when playing. But when walking close (or a tiny bit past) an edge, due to this "solution" I implemented, for a tiny moment the character stops moving forward while it turns on the same spot, due to the fact it is being reinstantiated.
I wonder if there is any other solution for this problem, other than using a kinematic character controller? I tried reducing the friction, but it induces other major problems caused by too low friction.
I am sure this should be a common problem for dynamic character controllers, so I hope that someone already faced this before and a better solution exists already... I really want to try keeping using a rigid body, as for everything else it is working great.
In the hope of being a little more clear, here follows a poorly drawn MS Paint image to explain my problem.
Thanks !
I am trying to use a dynamic (non-kinematic) character controller for my game, using the capsule shape as the collision shape.
It is working great, except for one case that I am not able to find a good solution so far.
When standing a tiny bit over an edge, the contact point between the ground and the bottom of the capsule shape is no longer perfectly centered in the middle of the capsule shape. In this scenario, if I induce a rotation (either by adding torque or adding angular speed), the capsule not only rotates, but also translates laterally.
I understand that this is the correct physics behavior, but I need to override it, because as much as it is dynamically correct (given the capsule shape and how friction/center of mass works), it is terrible for the character control.
Right now I am casting rays to check if the character is on an edge, and then reposition the rigid body on the desired position, instead of letting the physics control the rotation. This way I can force the capsule shape to "stay put" on the same place and avoid the unwanted translation.
This still feels wrong, as it induces a different behavior when rotating while walking a little bit past an edge, as the repositioning of the rigid body cancels any other movement components that were also applying forces to the body.
For example, when the character is walking on a flat surface, and I induce a rotation, the character naturally keeps moving forward while at the same time rotating. This is the correct behavior that feels very natural when playing. But when walking close (or a tiny bit past) an edge, due to this "solution" I implemented, for a tiny moment the character stops moving forward while it turns on the same spot, due to the fact it is being reinstantiated.
I wonder if there is any other solution for this problem, other than using a kinematic character controller? I tried reducing the friction, but it induces other major problems caused by too low friction.
I am sure this should be a common problem for dynamic character controllers, so I hope that someone already faced this before and a better solution exists already... I really want to try keeping using a rigid body, as for everything else it is working great.
In the hope of being a little more clear, here follows a poorly drawn MS Paint image to explain my problem.
Thanks !