How can I have my character stand still in a moving vehicle?

My character is in a moving train cabin. When I play,

the cabin moves along a spline.


My problem is that the character moves forward in the cabin and then collides with the wall

My problem is that my character wont stay still inside the cabin.
How could I fix this?
I’ve already changed and experimented with the characters “Character Movement (CharMovComp) (Inherited)” component because I thought that the problem had something to do with the physics.
These are some of the blueprints for the cabin…

Please tell me if you need more explanation.

Before I tackle the solution, I’m going to approach it with a few questions first.

  1. Does the cabin have to move? I ask because most of the time, that’s a “no” it only has to appear as though it is moving. That is easier to handle.

  2. Is the player “riding” the train or is the player supposed to be able to move around the train while it is in motion? If the first, then you can simply attach the character to a socket while boarded. If the the second, then it’s trickier.

  3. What happens if you just place the player character into the cabin and start the game? Unreal is pretty smart about things and most of the time, you don’t even need to do anything special. (I know in your example, you say the player moves forward but I doubt this is natural behavior. I’d bet you’re trying to match the cabin’s speed.)

So what would I do?

  1. Make the player a child of the cabin during that game mode. But this might not be ideal since child objects tend to ignore parent collisions.

or…

  1. Set the player’s position to the cabin’s position plus/minus some offset value so he can move around.
1 Like

Thanks for replying. I will answer your questions:

  1. Yes… at least that’s what my levels are set up for.
  2. I want both functions, but most of all I’d like the character to be able to move around in the vehicle.
  3. Having my character as a child of the moving cabin, not parenting the character and just placing it inside the cabin; both methods work better when I slow the cabin down. Your suggestion seemed to have solved the problem until I sped the cabin up.
    When it goes too fast the character is literally shot into “outer space”.

When the character is a child of the cabin the effect of the character moving forward is just allot stronger. Example : at the slower speed I can actually walk against the effect, but at the faster speed I can’t… I’m stuck to the wall.
That’s why having the character as a child of the cabin seemed like the better solution.

Like you said I may have to redesign the levels and create the illusion of movement.

Never mind, your suggestion worked, it turns out that in my level the sky sphere was colliding with my character, causing it to act very weirdly. I removed the sky and the method you suggested worked.
Thanks.

Happy to help!
Which method did you go with?

You can always set the sky sphere’s collision to none.

If it’s a custom sphere, go to the static mesh object and remove any collision. If it’s a blueprint, you can go to its collision settings and set it to none.

Simply placing the character inside the cabin without making it a child of the cabin .

I created a video demo of your question on my YouTube channel. I hope it helps others as well. Unreal Forum Question - How to Attach a Player to a Moving Platform - YouTube