How to replicate player on ship

Hello,

can somebody explain how to replicate player on ship while it’s moving? It works perfectly in singleplayer but when I launch dedicated player jumps even he throws himself from side to side. I’m certain it’s something I did wrong.

The issue here is that the server doesn’t consider what the player is doing to be “normal”, so it’s constantly trying to adjust its position. You need to update the player position server-side in cases like this.

Okey that explains this a bit. Thanks

Can you explain how to do this?

By update the player position server-side
you mean update player position with RPC to all clients?

yeah, that’s correct. once the player is “attached” to the the ship, the server should be in charge of setting and replicating its position.

The other way you could do this is adding “being on ship” to the CharacterMovementComponent. here’s how the documentation explains it:

Thanks a lot for your effort.
Will try that tomorrow.

What if I want player to be able to walk on ship while ship is moving?

Attach doesn’t seem to be best idea.

Can you explain how to add new movement to CharacterMovementComponent?

I don’t understand how to do it.

Can I do it in Character blueprint or I need to do it in C++ documentation doesn’t specify that.

well, i did say “attached”, do not actually attach the actors together.

you would have to do it in C++. Despite how cool Blueprint is, it’s not meant to implemente back-end features.

now, when the player is standing on the ship, and the ship is moving. the player moves with the ship because it checks for the movement of what’s bellow it. Sadly that only happens locally. server finds that really confusing as is not meant for multiplayer, so it’ll try to fight it.

However, you could have the input locally, and execute it only server-side. it might have lag, but at least the server will know what’s happening since it itself is doing the movement.

Something like player press Forward, sends a move request to server, server moves the character, client sees the movement being replicated.

Implementing new movements to the character moving component is so players can move locally without lag, and the server understands whats going on.

If you’re ok with a bit of lag (which might be imperceptible on a decent internet), then moving on server is your solution.

Thanks for this answer now I understand why this happends! Will try that.

I have created custom character and custom CharacterMovementComponent.

Should I use for example raycast to check if player is on ship or there is something else better buildin engine?

it would be enough to set a bool when player enters / leaves the ship.

You have said:

now, when the player is standing on the ship, and the ship is moving. the player moves with the ship because it checks for the movement of what’s bellow it

Can you please tell me what’s it’s name or give some link on API? I can’t find what is this.

Ctrl+F “Base” and a few highlights will show up.

main one i think being “Get Movement Base”

“base” is the name of the think moving under your character.

Thanks again!

Hey,

I have another question.

Can I force somehow to execute that on server too?

as you said:

“Sadly that only happens locally. server finds that really confusing as is not meant for multiplayer, so it’ll try to fight it.”