Prone position in multiplayer

Hello everyone.

I am working on FPSCharacter, the character created in the FPS tutorial on the wiki, I extended it to allow the player to switch between Standing, Crouch and Prone Positions, not using the default Crouch, UnCrouch() functions in Character.

Up until now I have everything working up consistently, every change in position gets called and replicated across the network in multiplayer for all characters in all clients and host, including the change in position for animations and the different sizes for the capsulecomponent. however, I cant set the SkeletalMesh to move upwards to be inside the capsulecomponent in the instances that have its role to ‘ROLE_SimulatedProxy’.

I have set a function goCrouched, activated by an Action Mapping, ‘B’ key pressed to make it Crouch or hold to make it go Prone.

	InputComponent->BindAction("goCrouched", IE_Pressed, this, &AFPSCharacter::OnStartToggleCrouch);
	InputComponent->BindAction("goCrouched", IE_Released, this, &AFPSCharacter::OnStopToggleCrouch);

Next, depending on the position chosen, I call the local function accordingly:

intPosition == 1    SetStand(1, false);
intPosition == 2    SetCrouch(1, false);
intPosition == 3    SetProne(1, false);

In each one of this functions, I get to repeat that ‘intPosition’ to the chosen one, since this Integer is replicated. Following that, it checks wether it is being called on a client, a proxy or the host, and calls either an RPC function marked Server or Multicast:

if (Role < ROLE_Authority)
	{
		ServerSetProne(bNewProne, bToggle);
	}
	else
	{
		MulticastSetProne(bNewProne, bToggle);
	}

The ServerSetProne() calls again SetProne() local function, and MulticastSetProne() changes the size of the capsulecomponent to its desired state.

void AFPSCharacter::MulticastSetProne_Implementation(bool bNewProne, bool bToggle)
{
	bWantsToChangePosition = true;
	intPosition = 3;
	bIsProne = bNewProne;

	bIsStand = 0;
	bIsCrouch = 0;

	//GetMesh()->RelativeLocation.Z = 25;
	float proneSize = GetCharacterMovement()->ProneHalfHeight;
	GetCapsuleComponent()->SetCapsuleSize(30, 30, true);
}

As I have said, everything works perfectly but the new location for the mesh, since I am changing the capsulecomponent size, the mesh gets lowered in relation to the capsule, only on the proxy characters, that is, the characters that are not onwned by the player controller, nor the host, in each client simulation.

image?

I would appreciate your help to implement the change in the location of the mesh to resemble the capsule position in the level. Thanks in advance.

Hi all

I finally figured it out: I oppened ‘charactermovementcomponent.cpp’, searching for the method that overwrites my SetRelativeLocation call, I copied SmoothClientPosition() to my custom character movement component and commented the line:

//CharacterOwner->GetMesh()->SetRelativeLocation(NewRelTranslation);

that was all it took, now the meshes are updated by the multicast function on all clients and server, so it is effectivelly working, obviouslly, I will keep an eye out for any side effects, I’ll soon upload the full documentation on the issue.

See you.

How we can speak about this problem? I have it too

Thank you.

Hi XelaSpain, I’ll be glad to help, i’ve just seen your forum post and I know what to do (in c++) Lets see what we can do about blueprints: As I dont see where is the PM interface, add me on Facebook, my site can be found as Onlogika.