TopDownProject network navsys : character client is as slow as possible

Hello,

I saw that I couldn’t use the NavSys on the client so I made a SetNewMoveDestinationServer function.
The SetNewMoveDestinationServer_Implementation will call SetNewMoveDestination to move the character, SUCCESS !

But… now the client character is as slow as possible. I don’t understand how and why. I mean it moves on the client and the server perfectly and it has all the animations but it moves at minspeed.

How can I fix that ?

rXp

Hard to tell. This should not be happening so it’s either a bug in movement code that we haven’t encountered yet, or it’s related to your SetNewMoveDestinationServer_Implementation. If you could share a stripped-down version of your project we could have a look and be more helpful.

Cheers,

–mieszko

As you can see I picked the TopDown project and build on it.
For now I don’t have much because I need multiplayer from the beginning.

Player controller class :
void AMyTopDownProjectPlayerController::PlayerTick(float DeltaTime)
{
Super::PlayerTick(DeltaTime);

	// keep updating the destination every tick while desired
	if (bMoveToMouseCursor)
	{
		MoveToMouseCursor();
	}

	if (bLaunchSelectedAction)
	{
		APawn* const pawn = GetPawn();
		AMyTopDownProjectCharacter* const character = Cast<AMyTopDownProjectCharacter>(pawn);
		character->LaunchAction();
		bLaunchSelectedAction = false;
	}
}

void AMyTopDownProjectPlayerController::MoveToMouseCursor()
{
	// Trace to see what is under the mouse cursor
	FHitResult Hit;
	GetHitResultUnderCursor(ECC_Visibility, false, Hit);

	if (Hit.bBlockingHit)
	{
		// We hit something, move there
		SetNewMoveDestination(Hit.ImpactPoint);
	}
}

void AMyTopDownProjectPlayerController::MoveToTouchLocation(const ETouchIndex::Type FingerIndex, const FVector Location)
{
	FVector2D ScreenSpaceLocation(Location);

	// Trace to see what is under the touch location
	FHitResult HitResult;
	GetHitResultAtScreenPosition(ScreenSpaceLocation, CurrentClickTraceChannel, true, HitResult);
	if (HitResult.bBlockingHit)
	{
		// We hit something, move there
		SetNewMoveDestination(HitResult.ImpactPoint);
	}
}

void AMyTopDownProjectPlayerController::SetNewMoveDestination(const FVector DestLocation)
{
	if (Role >= ROLE_Authority)
	{
		APawn* const Pawn = GetPawn();
		if (Pawn)
		{
			UNavigationSystem* const NavSys = UNavigationSystem::GetCurrent(this);
			float const Distance = FVector::Dist(DestLocation, Pawn->GetActorLocation());
			if (NavSys && (Distance > 120.0f))
			{
				NavSys->SimpleMoveToLocation(this, DestLocation);
			}
		}
		//test force update call event
		((AMyTopDownProjectCharacter* const)Pawn)->RepChar();
	}
	else{
		SetNewMoveDestinationServer(DestLocation);
	}
}

void AMyTopDownProjectPlayerController::SetNewMoveDestinationServer_Implementation(const FVector DestLocation)
{
	SetNewMoveDestination(DestLocation);
}

bool AMyTopDownProjectPlayerController::SetNewMoveDestinationServer_Validate(const FVector DestLocation)
{
	return true;
}

Thanks :slight_smile: it’s below

Anyone ? For now I update the velocity each time the pawn is moved by the navsys :
Pawn->GetMovementComponent()->Velocity = Pawn->GetMovementComponent()->Velocity * 10;

But… it is ugly and can lead to issues in MP.

Can anyone help me ?

rXp

I’ve used up some time trying to build a repro-project from what you posted just to find out it’s not all that’s required. If you want us to look at it please share a complete (even though if a stripped-down) version of your project.

Cheers,

–mieszko

This is a stripped down old version of my project.
You will see the Pawn->GetMovementComponent()->Velocity = Pawn->GetMovementComponent()->Velocity * 10; to “fix temporarily” the issue in the charactercontroller.

I had to remove the map file to be able upload it. The map/level file is only a square with some rocks that have collision.
link text