How to make a convincing ground inertia?

Hi there!

Here's my situation: I am making a game which involves the player being on a train moving really really fast. The problem is that the game is based upon the movements of the train, which does loops, barrel rolls and stuff and the player has to not fall out of it, so i can't just fake the trains movements by moving the outside set instead.

Now the issue i'm having, as you read the title, is that i cannot, for the love of me, find a way to do a convincing (nor even working and "universal") inertia for the player. I mean i first wanted to make the character's world moves always affected by the ground's moves (by applying the ground's speed or anything every frame) but it turned out lame and not working at all, so i decided to parent the player to the ground, and unparent it every time he wasn't on the ground, and only then apply a force in the direction the ground was going. That also turned out not working at all, because of the huge speed of the ground and the inaccuracy of the addforce; making it, at best, landing back or forth of the position he jumped from, and having to find the exactly accurate multiplier for the impulse force, which was something around 200.000 or something, which is stupid. So another way i thought about was to add a ground "tracker" at the player's feet and parent that to the ground instead of the player, make the player follow its x and z values when on the ground (not the y, to make it possible for the ground to suddenly go down, making the player "hover" and start falling, which would be awesome), but then again, adding a force when jumping wasn't an option, so keep the ground tracker on the ground as long as the ground isn't too far below the player (an arbitrary serialized value), and then only add an impulse to simulate an inertia.

With this solution, not only is the impulse not working again (cause having to multiply the ground "speed" (calculated by subtracting the last frame's ground's position by the current one) by a huge value for some reason i don't even understand anymore, and because the train's ground might have some holes in it that the player should be able to jump over without being counted as "falling"). The other problem being that the entire game's based on a grappling the player uses to move around the train (zelda-like grappling (attracting, not swinging)), so theorically the player would be in the air most of the time so..

Anyway so, after litterally one month of attempts and failures, i'm starting to feel really tired of this problem and i'm beginning to lose any understanding i have about anything, about how the unity physics works exactly (the addforce never works exactly as i intend for example), and i'm running out of ideas on how to make that damned inertia, so i'm turning to you to see if you would have any idea on how to make this thing work please?

1 Reply

A rather late reply since I'm only seeing this now, but you only need to rely on the physics systems already in place within unity. If you have friction between the player and the train, the player should move along with the train. Looking at the video, the problem is not that the player doesn't appear to be moving with the train, but that the train is accelerating unrealistically fast, so its only natural that the player would fall off (try pulling out a sheet of paper from underneath an object slowly, and then really really quickly, and you'll see what I mean). Also keep in mind that while the train is moving at a constant velocity, the player would realistically see the train as stationary from their point of view due to relativity. If you're looking to have unrealistic, wild movements on the train, then you will need to adjust things such as gravity, friction and whatnot appropriately in order to keep the player on the train.