Player Floats and Sinks when Crouching in multiplayer

I am working on a multiplayer game at the moment, I have managed to get most animations and actions to replicate pretty well. The problem is that other players will appear to sink and float when crouching. It does not happen when moving, only stationary.

This only appears to other clients, the player in question will see no problem in their location

Bellow I have attached a gif of my problem

230281-ue4problem.gif

Make the capsule visible and not hidden-in-game and if it doesn’t help you see the problem post a GIF of that for us to see.

Thanks for the speedy response, the capsule shrinks to a ball, and stays like that even when walking. I am using the engines built in “is crouching” as apart of the movement component

230323-porblem2.gif

Additionally, here you can see the client is normal. but not for the other client

Right. And you had to position your mesh relative to the capsule. So when the capsule height changes, the mesh is no longer in the correct relative location. When you crouch, you need to set the mesh location so it doesn’t fall through the floor as the capsule center gets lower.

Usually you want to get the capsule’s scaled half height, negate it, and apply it to the Z axis of the relative location of the mesh.

Oh right. The owning client tells the server to crouch so they both work. It seems the other clients do not get in on the event so they can do whatever the owning client does to adjust the mesh location. It’s hard to say without seeing the relevant code. But you may need to either use a multicast RPC or a RepNotify to tell the other clients that they need to call the crouch code too.

This is still ruining my life. Sorry I let the thread die, I thought i would manage to fix the replication down the line. I was wrong. I am losing sleep. The crouch replicates on the server. Crouch maintains base location. I do not know what is wrong

233462-kilme.gif

It works on a ?listen server, only for the server player. Something is not replicating with the crouch function, or un crouch function. Help me please

233463-kilme2.gif

I still don’t have enough information to help you any more than I have. Can you share the project or provide an example project with the issue?

Another option is to take a look at [this][1] project. It provides a character capsule with its origin at ground-level. That way you don’t need to reposition the mesh when you crouch/stand. I’m using it in my main project and it has worked really well with players and AI (but I can’t guarantee it handles everything, it’s just doing as much as I need it to). You should be able to get the classes into your own project. Note: this will require adding C++ to your project – if you haven’t already. Oh, and it’s working with 4.18.3. It should work with more than that but I can’t say because I haven’t tried.

[1]:

Its a mess right now but this is the crouch command, I know it probably shouldnt look like this but this is the best i could get it working.

i noticed this guy had the same problem, and it was related to an engine problem.

Thank you so much for your generous help, I fixed it by allowing the skeletal mesh and its parent replicate on a server. I am an idiot. Didn’t think this would be a problem since it already kind of does replicate. Cleaning up my BP now.

That’s weird. No one does it that way so I’m surprised it worked. Check out the comment I am leaving above. You don’t need all that RPC.

I’ve never used Crouch and Uncrouch. I always handled it myself. I can see that Crouch and Uncrouch handle replication for you. You only need to call them on the owning client. You don’t need server or multicast RPC.

What you want to do is adjust the location of the character mesh. There are events OnStartCrouch and OnEndCrouch. When those trigger, you want to change the location of your character mesh relative to the center of the capsule. Use SetRelativeLocation with the right Z location and they will all show the right heights at the right times.

if(Crouched)
{
Capsule->SetCapsuleHalfHeight(CrouchedHalfHeight);
Mesh->SetRelativeLocation(CrouchedHeightAdjustVector);
OwnerActor->UpdateComponentTransforms();
}
else
{
Capsule->SetCapsuleHalfHeight(HalfHeight);
Mesh->SetRelativeLocation(HalfHeightAdjustVector);
OwnerActor->UpdateComponentTransforms();
}

sorry for the necro but I just got here for same reason, need to call parent methods when overriden OnStartCrouch and OnEndCrouch