Gravity boots camera / player / rotation /stabilization / smoothing

Hello i dont know if this is the right place or something like this is already done.

But my problem is i have coded gravity boots to stick on any surface. I can run around a cube. That on its own is cool but if id say i have some mesh with many faces like an asteroid or something like that, the player attaches to the faces and that creates an absolutely awful wobbleness for the camera. And i cant really watch it without getting sick (not vr)

Im using a Raycast Sphere to get the normal of the surface and allign the players up vector to it with some quaternions. Now the camera goes with the player object.

The game SpaceEngineers has this issue too, which this is based on :wink:

So my question is if you have some ideas on how to smooth the camera wobble. I can give some code later if anyone wishes.

Great to see other Space Engineers enthusiasts :smile:. Well it’s a difficult topic. Of course you could smooth the alignment, but that makes it slower / less responsive in case a strong change in direction is happening which is also not wanted. So I think the best approach is to define a threshold of the “normal delta” from frame to frame and apply a strong smoothing behaviour if the angle is “small” and a quite fast alignment if the delta is “large”. What you should consider small or large is up to you.

Another thing you may do as well is to do multiple raycasts, possible in a 3x3 / 5x5 / … grid around the player to gather a larger amount of surface information around the player. You may even ignore the actual vertex normal information of the hits but instead use the hitpoints of the raycasts to essentially span a virtual plane between those and calculate the normal(s) of those planes and use those as an alignment guide. Though this can quickly becomes quite complex and has its own edge cases you would have to think about. Some raycasts may not hit anything.

Yet another approach may be to do some kind of hybrid alignment. Technically even a relatively large asteroid has a tiny gravitational field. Probably too weak to even mention it as it would accelerate you by 0.001 m/s towards the center of mass of the asteroid. However you could use the center of mass as an additional guide what alignmeht you should choose. Of course you would only take it into account, if the rough orientation aligns with the gravitational “ground” so you get a better result (like having a spherical gravity generator in the center of the asteroid). Since you probably want to be able to walk upside down on overhangs, again there has to be a threshold when to ignore or how to fade out the influence of the center of mass. Those are all just tiny puzzle pieces which could help to improve the feel.

Your title said “camera stabilization” but it actually applies to your whole player. This is of course also relevant when you have collisions as you walk in a tiny space which makes things more complicated as well. Even SE has some nasty issues where you can get easily stuck in such situations and the only solution is to enable the jetpack. In such a high dynamic environment there are just infinite edge cases. You could try to implement individual solutions for certain “edge case groups” which you have to identify first.

As a general smoothing tool you usually don’t want to snap to the new normal that is directly under your feet but calculate the interpolated normal between neighboring faces based on where you are between those faces. Though everything has a limit. You know in SE the smallest solid voxel is tiny (much to the grief of large ships which fly into them ^^). So having a +90° change within a few cm, there’s not much you can do about it when you move relatively fast. You either spin around quickly to stay on it, or your loose grip and float away.

In a lot older FPS games (I think of Half-life) you could stand on the ledge of a single polygon which only had a width of 0.1, so barely visible. Though you could perfectly stand on such a ledge. Other games intentionally require a certain amount of flat surface to stand on, otherwise you slide off. You have to find a solution that fits your idea. Games always live between fiction and reality and it’s up to you to decide where you want your game to be placed.

1 Like

Yea thank you for your reply and thoughts :wink:
I firstly thought maybe i could in some way just smooth the rotation of the camera to get an effect that is not nauseating.

I see your opinions and will think about it more ^^

My code lets me rotate to edges from a cube easily without falling off. That is desired but it could really be quite complicated to add more raycasts and interpolate between them.

i tried thinking about to just slow down the rotation.

but anyway thanks for your reply and your good ideas :wink:
i will try my best to test them out. im not really an expert with quaternions and stuff and i did just throw together some variables multiplied divided until it worked xD

UPDATE: Slowing down the rotation speed works kinda. I now detect if its an Asteroid or a SpaceShip with tags. Just if 3 or more “asteroids” “ships” are submerged into one the intersection point will cause some problem. But i dont think it is super important to fix it because i dont think 3 overlapping asteroids would ever be the case xD. But i try to fix it anyway ^^