I’m trying to recreate the physics of a very old game.
I’ve reverse engineered what is done, and all the colliders basically just get scaled down vertically in order to allow the player to move past slopes/steps easier (and other math that doesn’t really matter for this topic).
I get that this approach might be a bit odd, but is there any way how I can achieve this with good performance?
I don’t want to use rigidbodies and “guess” to get a rough estimate of how it behaves in the game I compare to.
I move the player with a custom character controller, no rigidbody.
Currently, I scale the entire scene down to the desired scale and call Physics.SyncTransforms();
This approach is not good on performance.
Any ideas how I could achieve this?
This is never going to be good performance-wise. Physics obviously isn’t like a renderer, it has a structure it stores objects such as colliders (the shapes colliders produce to be accurate) known as a broadphase which is a spatial database. It does this extra step because it makes it much faster to perform queries, calculate contacts etc. When you modify something like a Collider all this has to be updated.
Most of physics is designed to not be modified/scaled and for the most part, try to stay immutable. The only things that move in physics are bodies; colliders go along for the ride.
You’re essentially working against this which is why you’ll get terrible performance.
I have no idea what effect you’re going for but why scale the whole scene? Why not scale the fewer things such as the player and adjust the camera? Less things to scale is less work is better performance.
If I scale up the player vertically, yet leave the scene untouched, slopes would remain the same angle, therefore the physics wouldn’t be the same as what I’m going for afaik
This is what the physics I try to replicate are doing.
Top image is what it looks like, and how the player positions itself.
Bottom image is how the collisions act, for slopes and stairs.
Maybe this is somehow exactly achievable in some other way that isn’t estimated (with code and not a custom collider)?