Download

Hard Replication Issue Tick() Too much calls

Hellow fellows !

I’m here cause i’m stuck in the mud !

Where building a 12 player 0-Gravity game, with movement based on force (So working the UPrimitiveComponent).

I made a lot of work on the movement, until I had to developp a custom movementComponent, and thus used my own Replication calls…

Someone told me to put movement Reaction to Input inside the Tick function (Blueprint tick is at 0.0). The movement interaction aren’t replicated, it’s the position/velocity that are rep.
Thing is, i putted the replication function inside the tick function… I do fell like it’s a bad idea now, server can’t accept more than 3 client, if one more tries to connect, he does symply cannot, BeginPlay() function isn’t called…

I’m not enough experienced to know how much data/calls (ko/s) can sustain UE4.

My question is, theorically, in term of robustness, how much time per seconds should i replicate position/velocity for having both smoothness and ability to have 12 player on my server ?


void A*********Character::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	
	_Initialized = true;

	AController* PC = Cast<AController>(Controller);
	if (PC)
	{

		if (this == Cast<A********BallCharacter>(UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetPawn())) // Is the local player controller?
		{
			if (_GrabbedBy)
				_CurrentState = _AllStateStruct._GrabebStateMovement;
			else if (_CurrentState == _AllStateStruct._GrabebStateMovement)
				_CurrentState = _AllStateStruct._FlyMovementComp;

			_CurrentState->Move(); //Calcullate speed
			_CurrentState->Roll(); //Turn _Character
			_CurrentState->ApplyGravity(DeltaTime);
 
			if(!_GrabbedBy)
				Set_Loc(GetRootComponent()->GetComponentLocation(), _PrimComp->GetPhysicsLinearVelocity()); // Here
		}
	}

	if( Role == ROLE_SimulatedProxy ||  GetController() != GetWorld()->GetFirstPlayerController()) 
		MoveTo();
	

	_PrimComp->SetPhysicsAngularVelocity(FVector(0.0f));

	if (_CurrentState == _AllStateStruct._FlyMovementComp)
	{
		GetCapsuleComponent()->SetCapsuleRadius(_CapsuleRadius * (1 + GetSpeed() * 0.02), true);
		GetCapsuleComponent()->SetCapsuleHalfHeight(90.0f * (1 + GetSpeed() * 0.01));
	}
	else
	{
		GetCapsuleComponent()->SetCapsuleRadius(_CapsuleRadius, true);
	}
}

void A*********BallCharacter::Set_Loc(FVector loc, FVector dir)
{
	_ActorLocation = loc;
	_ActorDirection = dir;
	_ActorRotation = GetRootComponent()->GetComponentRotation();
	_CameraDirection = _FpsCamera->GetForwardVector().ToOrientationRotator();

	if (Role == ROLE_Authority) 
		Server_set_Loc_Better(loc.X, loc.Y, loc.Z, dir.X, dir.Y, dir.Z, GetRootComponent()->GetComponentRotation(), _FpsCamera->GetForwardVector().ToOrientationRotator());
	else
	{
		Client_To_Server_set_Loc_Better(loc.X, loc.Y, loc.Z, dir.X, dir.Y, dir.Z, GetRootComponent()->GetComponentRotation(), _FpsCamera->GetForwardVector().ToOrientationRotator());
	}
		
}