Gnollrunner said:
We are apparently giving advice about two different algorithms.
Yes. But you can make a good character controller with allowed penetration - it's not a bug.
And my proposal is not related to physics simulation either. No velocities or forces - just minimizing penetration.
So it's up to anyone to make a choice. I have used both methods in the past and can't tell any general preference. Both have their limitations, issues and devils in the details.
Physics engines mostly use a mix both methods.
For example, if we only do sweeping along movement to prevent collisions, such method has no way to resolve penetrations in case they happen anyway (which they will). If a penetrating body has zero velocity, there is no point in time to find where the collision happened, so a pure sweeping method will not resolve the penetration.
So you always need to deal with penetration in a non physical way, e.g. by separating intersecting bodies slowly but not affecting velocity or generating forces eventually.
Basically a hack, necessary because in practice you can't guarantee to avoid penetrations.
What we mostly see is sweeping actually only used if an optional Continuous Collision Detection feature is enabled. That's expensive, and usually only used for fast moving bodies. Iirc, Bullet for example always uses the approximation of treating any body like a sphere for its CCD feature, so not very accurate.
The most important way to deal with collisions is indeed a set of multiple contact points, and each contact has some penetration going on, which it tries to minimize, similar to how i proposed. But ofc. solving for contact forces of multiple dynamic bodies trying to respect laws of physics is much harder then our proposals here.
However, afaict pretty any game engine implements its character controller using its physics engine, because it already exposes all required and optimized functionality.
Stand alone Physics Engines also usually have a character controller built in. It's a standard feature. So i don't agree with sweeping being the general way to handle collisions for character controllers, which usually move rather slowly.
But they are not purely physical either. Mostly they are implemented using kinematic bodies, giving more control about how it feels, how they interact with other dynamic bodies, etc.
It's also common to gather a set of nearby faces, and using raytracing sensors to prevent collisions from happening, or to handle difficult movement like stepping stairs.
So it's a mix of various things, and implementations differ a lot across games if we go into details.
There surely is no point to argue which methods are better or what we should or shouldn't recommend. Sharing some things which worked for us is all we can do.