I’m facing a problem with replicating the movement of a player’s drone.
The logic of the player’s drone is working in single game mode, but in multi-player mode the movement is not replicated.
The drone is a ACharacter type.
Header file:
/**
* @brief AKDroneCharacter is owned by a player character.
* The drone has a camera and is guided by the player.
*/
UCLASS()
class KSGM_API AKDroneCharacter : public ACharacter
{
GENERATED_UCLASS_BODY()
public:
virtual void PostInitializeComponents() override;
virtual void PossessedBy(AController* NewController) override;
virtual void UnPossessed() override;
virtual void Restart() override;
/** cleanup */
virtual void Destroyed() override;
UFUNCTION(BlueprintCallable, Category = Team)
virtual FLinearColor GetTeamColor() const;
virtual void NotifyTeamChanged();
virtual void PlayerChangedTeam();
/** Returns the master controller for this actor. */
UFUNCTION(BlueprintCallable, Category = Pawn)
class AKPlayerController* GetMasterController() const;
/** Called when Master Controller is replicated */
UFUNCTION()
virtual void OnRep_MasterController();
/**
<summary>The basic attributes of the character</summary>
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "DefaultAttributes")
FKBasicAttributeStruct BasicAttributes;
/**
<summary>The computed basic attributes of the character</summary>
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "ComputedAttributes")
FKBasicAttributeStruct ComputedBasicAttributes;
/** Controller currently mastering this Actor */
UPROPERTY(replicatedUsing = OnRep_MasterController)
class AKPlayerController* MasterController;
….
}
Source file:
AKDroneCharacter::AKDroneCharacter(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
// The default basic attributes for this drone
BasicAttributes.Defaults();
bWantsToRun = false;
bIsDying = false;
GetMesh()->bReceivesDecals = false;
GetMesh()->SetCollisionObjectType(ECC_Pawn);
GetMesh()->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
GetMesh()->SetCollisionResponseToChannel(COLLISION_WEAPON, ECR_Block);
GetMesh()->SetCollisionResponseToChannel(COLLISION_PROJECTILE, ECR_Block);
GetMesh()->SetCollisionResponseToChannel(COLLISION_SPELL, ECR_Ignore);
GetMesh()->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block);
GetMesh()->SetEnableGravity(false);
GetCapsuleComponent()->SetCollisionResponseToChannel(ECC_Camera, ECR_Ignore);
GetCapsuleComponent()->SetCollisionResponseToChannel(COLLISION_PROJECTILE, ECR_Block);
GetCapsuleComponent()->SetCollisionResponseToChannel(COLLISION_SPELL, ECR_Ignore);
GetCapsuleComponent()->SetCollisionResponseToChannel(COLLISION_WEAPON, ECR_Ignore);
GetCapsuleComponent()->SetEnableGravity(false);
// This is a flying character
GetCharacterMovement()->bOrientRotationToMovement = false;
GetCharacterMovement()->bUseControllerDesiredRotation = true;
//GetCharacterMovement()->bRunPhysicsWithNoController = true;
GetCharacterMovement()->SetMovementMode(EMovementMode::MOVE_Flying);
GetCharacterMovement()->DefaultLandMovementMode = EMovementMode::MOVE_Flying;
GetCharacterMovement()->DefaultWaterMovementMode = EMovementMode::MOVE_Flying;
// set our turn rates for input
BaseTurnRate = 45.f;
BaseLookUpRate = 45.f;
SetReplicates(true);
SetReplicateMovement(true);
bAlwaysRelevant = true;
PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.TickGroup = TG_PrePhysics;
//SetRemoteRoleForBackwardsCompat(ROLE_SimulatedProxy);
PrimaryActorTick.bStartWithTickEnabled = true;
PrimaryActorTick.bAllowTickOnDedicatedServer = true;
}
/*
* Replication
*
*/
void AKDroneCharacter::PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker)
{
Super::PreReplication(ChangedPropertyTracker);
// Only replicate this property for a short duration after it changes so join in progress players don't get spammed with fx when joining late
DOREPLIFETIME_ACTIVE_OVERRIDE(AKDroneCharacter, LastTakeHitInfo, GetWorld() && GetWorld()->GetTimeSeconds() < LastTakeHitTimeTimeout);
}
void AKDroneCharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
// everyone except local owner: flag change is locally instigated
DOREPLIFETIME_CONDITION(AKDroneCharacter, bWantsToRun, COND_SkipOwner);
DOREPLIFETIME_CONDITION(AKDroneCharacter, LastTakeHitInfo, COND_Custom);
// everyone
DOREPLIFETIME_CONDITION(AKDroneCharacter, BasicAttributes, COND_None);
DOREPLIFETIME_CONDITION(AKDroneCharacter, ComputedBasicAttributes, COND_None);
}
void AKDroneCharacter::PostInitializeComponents()
{
Super::PostInitializeComponents();
UE_LOG(LogDebug, Verbose, TEXT("AKDroneCharacter::PostInitializeComponents - Role=%s IsLocallyControlled=%i Actor=%s"), NETROLETOSTRING(Role), IsLocallyControlled(), *GetName());
// Copy basic attributes to computed attributes
ComputedBasicAttributes = BasicAttributes;
// play respawn effects
if (GetNetMode() != NM_DedicatedServer)
{
if (RespawnFX)
{
UGameplayStatics::SpawnEmitterAtLocation(this, RespawnFX, GetActorLocation(), GetActorRotation());
}
if (RespawnSound)
{
UGameplayStatics::PlaySoundAtLocation(this, RespawnSound, GetActorLocation());
}
}
}
void AKDroneCharacter::Destroyed()
{
AKDroneCharacterController* PC = Cast<AKDroneCharacterController>(Controller);
UE_LOG(LogDebug, Verbose, TEXT("AKDroneCharacter::Destroyed - Role=%s IsLocallyControlled=%i Actor=%s Controller=%s"), NETROLETOSTRING(Role), IsLocallyControlled(), *GetNameSafe(this), (PC) ? *GetNameSafe(PC) : TEXT("None"));
Super::Destroyed();
}
void AKDroneCharacter::PossessedBy(AController* NewController)
{
UE_LOG(LogDebug, Verbose, TEXT("AKDroneCharacter::PossessedBy - this=%s NewController=%s"), *GetNameSafe(this), *GetNameSafe(NewController));
SetOwner(NewController);
Super::PossessedBy(NewController);
AKDroneCharacterController* PC = Cast<AKDroneCharacterController>(Controller);
if (PC != nullptr)
{
PC->SetPawn(this);
}
}
void AKDroneCharacter::UnPossessed()
{
UE_LOG(LogDebug, Verbose, TEXT("AKDroneCharacter::UnPossessed - Role=%s IsLocallyControlled=%i Actor=%s"), NETROLETOSTRING(Role), IsLocallyControlled(), *GetName());
Super::UnPossessed();
}
void AKDroneCharacter::Restart()
{
UE_LOG(LogDebug, Verbose, TEXT("AKDroneCharacter::Restart - Role=%s IsLocallyControlled=%i Actor=%s"), NETROLETOSTRING(Role), IsLocallyControlled(), *GetName());
Super::Restart();
ClearJumpInput();
}
void AKDroneCharacter::DroneTurnAtRate(float Rate)
{
if ((Controller != NULL) && (Rate != 0.0f))
{
// calculate delta for this frame from the rate information
const FRotator Rotation = Controller->GetControlRotation();
Controller->SetControlRotation(FRotator(Rotation.Pitch, Rotation.Yaw + ( Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds() ), Rotation.Roll));
}
}
void AKDroneCharacter::DroneMoveRight(float Value)
{
UE_LOG(LogDebug, VeryVerbose, TEXT("AKDroneCharacter::DroneMoveRight - Value=%f"), Value);
if ((Controller != nullptr) && (Value != 0.0f))
{
// find out which way is right
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
// get right vector
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
// add movement in that direction
AddMovementInput(Direction, Value);
}
}
void AKDroneCharacter::DroneMoveUp(float Value)
{
UE_LOG(LogDebug, VeryVerbose, TEXT("AKDroneCharacter::DroneMoveUp - Value=%f"), Value);
if ((Controller != NULL) && (Value != 0.0f))
{
// find out which way is right
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
// get right vector
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Z);
// add movement in that direction
AddMovementInput(Direction, Value);
}
}
The drone’s controller is very simple.
Header file:
UCLASS(config = Game)
class KSGM_API AKDroneCharacterController : public AController
{
GENERATED_UCLASS_BODY()
// Begin AController interface
virtual void GameHasEnded(class AActor* EndGameFocus = NULL, bool bIsWinner = false) override;
virtual void Possess(class APawn* InPawn) override;
virtual void BeginInactiveState() override;
virtual void OnRep_Pawn();
virtual void SetPawn(APawn* InPawn);
// End APlayerController interface
};
Source files:
AKDroneCharacterController::AKDroneCharacterController(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
void AKDroneCharacterController::SetPawn(APawn* InPawn)
{
UE_LOG(LogOnline, Log, TEXT("AKDroneCharacterController::SetPawn this=%s Role=%s IsLocalController()=%i InPawn=%s"), *GetNameSafe(this), NETROLETOSTRING(Role), IsLocalController(), *GetNameSafe(InPawn));
Super::SetPawn(InPawn);
}
void AKDroneCharacterController::OnRep_Pawn()
{
UE_LOG(LogOnline, Log, TEXT("AKDroneCharacterController::OnRep_Pawn - this=%s GetPawn()=%s"), *GetNameSafe(this), *GetNameSafe(GetPawn()));
Super::OnRep_Pawn();
}
void AKDroneCharacterController::Possess(APawn* InPawn)
{
UE_LOG(LogOnline, Log, TEXT("AKDroneCharacterController::Possess - this=%s InPawn()=%s"), *GetNameSafe(this), *GetNameSafe(InPawn));
Super::Possess(InPawn);
}
void AKDroneCharacterController::BeginInactiveState()
{
Super::BeginInactiveState();
AGameState* GameState = GetWorld()->GetGameState<AGameState>();
}
void AKDroneCharacterController::GameHasEnded(AActor* EndGameFocus, bool bIsWinner)
{
// Stop any movement we already have
StopMovement();
}
The player owns the drone. The drone is created when the player’s character is created. No problem with the player’s character. Perfectly replicated.
The player’s character is also a ACharacter type.
The move of the player’s drone is done by the player’s character and not the drone itself. This is working in single player mode.
Source file:
AKPlayerCharacter::AKPlayerCharacter(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
// Create the automatic collection sphere for automatic collectable objects
AutomaticCollectionSphere = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("AutomaticCollectionSphere"));
AutomaticCollectionSphere->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
// Set the radius for the collection sphere
AutomaticCollectionRadius = 200.f;
AutomaticCollectionSphere->SetSphereRadius(AutomaticCollectionRadius);
AutomaticCollectionSphere->OnComponentBeginOverlap.AddDynamic(this, &AKPlayerCharacter::OnBeginOverlapAutomaticCollectionSphere);
// Set the channel responses
AutomaticCollectionSphere->SetCollisionResponseToChannel(COLLISION_PROJECTILE, ECR_Ignore);
AutomaticCollectionSphere->SetCollisionResponseToChannel(COLLISION_SPELL, ECR_Ignore);
AutomaticCollectionSphere->SetCollisionResponseToChannel(COLLISION_WEAPON, ECR_Ignore);
// We want to generate an overlap event for guided actors
AutomaticCollectionSphere->SetCollisionResponseToChannel(COLLISION_GUIDED, ECR_Overlap);
// Create the detection pickup box for pickup collectable objects
DetectionPickupBox = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, TEXT("DetectionPickupBox"));
DetectionPickupBox->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
// Set the box extent for the pickup box
DetectionBoxExtent.X = 110.0f;
DetectionBoxExtent.Y = 50.0f;
DetectionBoxExtent.Z = 100.0f;
DetectionPickupBox->SetBoxExtent(DetectionBoxExtent);
DetectionPickupBox->OnComponentBeginOverlap.AddDynamic(this, &AKPlayerCharacter::OnBeginOverlapDetectionPickupBox);
DetectionPickupBox->OnComponentEndOverlap.AddDynamic(this, &AKPlayerCharacter::OnEndOverlapDetectionPickupBox);
// Set the channel responses
DetectionPickupBox->SetCollisionResponseToChannel(COLLISION_PROJECTILE, ECR_Ignore);
DetectionPickupBox->SetCollisionResponseToChannel(COLLISION_SPELL, ECR_Ignore);
DetectionPickupBox->SetCollisionResponseToChannel(COLLISION_WEAPON, ECR_Ignore);
DetectionPickupBox->SetCollisionResponseToChannel(COLLISION_GUIDED, ECR_Ignore);
// Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);
// set our turn rates for input
BaseTurnRate = 45.f;
BaseLookUpRate = 45.f;
// Don't rotate when the controller rotates. Let that just affect the camera.
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
// Configure character movement
GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...
GetCharacterMovement()->RotationRate = FRotator(0.0f, 540.0f, 0.0f); // ...at this rotation rate
GetCharacterMovement()->JumpZVelocity = 600.f;
GetCharacterMovement()->AirControl = 0.2f;
// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = ObjectInitializer.CreateDefaultSubobject<USpringArmComponent>(this, TEXT("CameraBoom"));
CameraBoom->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
CameraBoom->TargetArmLength = 300.0f; // The camera follows at this distance behind the character
CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller
CameraBoom->SetRelativeRotation(FRotator(0.0f, 0.0f, 0.0f));
// Create a follow camera
FollowCamera = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("FollowCamera"));
FollowCamera->AttachToComponent(CameraBoom, FAttachmentTransformRules::KeepRelativeTransform, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
FollowCamera->bUsePawnControlRotation = true; // Rotate the arm based on the controller
// The current camera offset (Up/Down) in third person
CameraBoomOffsetZ = 0.0f;
// These values are in DefaultGame.ini
CameraBoomUpDownIncrement = 25.0f;
CameraBoomMinOffsetZ = 100.0f;
CameraBoomMaxOffsetZ = 300.0f;
CameraBoomTargetArmLengthMax = 500.0f;
// Create a camera boom (pulls in towards the player if there is a collision)
FrontCameraBoom = ObjectInitializer.CreateDefaultSubobject<USpringArmComponent>(this, TEXT("FrontCameraBoom"));
FrontCameraBoom->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
FrontCameraBoom->TargetArmLength = 200.0f; // The camera follows at this distance behind the character
FrontCameraBoom->bUsePawnControlRotation = false; // Rotate the arm based on the controller
FrontCameraBoom->SetRelativeRotation(FRotator(0.0f, 180.0f, 0.0f));
// Create a follow camera
FrontCamera = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("FrontCamera"));
FrontCamera->AttachToComponent(FrontCameraBoom, FAttachmentTransformRules::KeepRelativeTransform, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
FrontCamera->bUsePawnControlRotation = false; // Rotate the arm based on the controller
FrontCamera->Deactivate();
IsFrontCameraActive = false;
TargetTempSpeedFactor = InitialTempSpeedFactor = 0.0f;
InitialEnergyLevel = IncEnergyLevel = 0.0f;
InitialPowerLevel = IncPowerLevel = 0.0f;
LeftPreviousClickedWeaponIndex = -1;
RightPreviousClickedWeaponIndex = -1;
SpawnedDrone = nullptr;
}
void AKPlayerCharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AKPlayerCharacter, SpawnedDrone);
}
void AKPlayerCharacter::PostInitializeComponents()
{
Super::PostInitializeComponents();
}
//////////////////////////////////////////////////////////////////////////
// Input
void AKPlayerCharacter::SetupPlayerInputComponent(class UInputComponent* InInputComponent)
{
// Set up gameplay key bindings
check(InInputComponent);
InInputComponent->BindAxis("MoveForward", this, &AKPlayerCharacter::MoveForward);
InInputComponent->BindAxis("MoveRight", this, &AKPlayerCharacter::MoveRight);
InInputComponent->BindAxis("DroneMoveForward", this, &AKPlayerCharacter::DroneMoveForward);
InInputComponent->BindAxis("DroneMoveRight", this, &AKPlayerCharacter::DroneMoveRight);
InInputComponent->BindAxis("DroneTurnAtRate", this, &AKPlayerCharacter::DroneTurnAtRate);
InInputComponent->BindAxis("DroneMoveUp", this, &AKPlayerCharacter::DroneMoveUp);
…..
}
void AKPlayerCharacter::Restart()
{
UE_LOG(LogDebug, Verbose, TEXT("AKPlayerCharacter::Restart - Role=%s IsLocallyControlled=%i Actor=%s"), NETROLETOSTRING(Role), IsLocallyControlled(), *GetName());
Super::Restart();
if (IsLocallyControlled())
{
// Create the drone when restarting the player character
SpawnDrone();
}
}
void AKPlayerCharacter::OnRep_SpawnedDrone()
{
UE_LOG(LogDebug, Verbose, TEXT("AKPlayerCharacter::OnRep_SpawnedDrone - Role=%s IsLocallyControlled=%i SpawnedDrone=%s"), NETROLETOSTRING(Role), IsLocallyControlled(), *GetNameSafe(SpawnedDrone));
}
void AKPlayerCharacter::SpawnDrone()
{
UE_LOG(LogDebug, Verbose, TEXT("AKPlayerCharacter::SpawnDrone - Role=%s IsLocallyControlled=%i"), NETROLETOSTRING(Role), IsLocallyControlled());
// If we are on the server, spawn the drone locally
if (Role == ROLE_Authority)
{
LocalSpawnDrone();
}
else
{
// If we are a client call the server function to stay in sync
ServerSpawnDrone();
}
}
bool AKPlayerCharacter::ServerSpawnDrone_Validate() { return true; }
void AKPlayerCharacter::ServerSpawnDrone_Implementation()
{
UE_LOG(LogDebug, Verbose, TEXT("AKBaseCharacter::ServerSpawnDrone_Implementation - Role=%s IsLocallyControlled=%i Actor=%s"), NETROLETOSTRING(Role), IsLocallyControlled(), *GetName());
LocalSpawnDrone();
}
void AKPlayerCharacter::LocalSpawnDrone()
{
UE_LOG(LogDebug, Verbose, TEXT("AKBaseCharacter::LocalSpawnDrone - Role=%s IsLocallyControlled=%i"), NETROLETOSTRING(Role), IsLocallyControlled());
// Do we have a Drone ?
// For an actor only spawned on the server side
// never on the client.
UE_LOG(LogDebug, VeryVerbose, TEXT("AKPlayerCharacter::LocalSpawnDrone - Drone=%s"), *GetNameSafe(Drone));
if (Role == ROLE_Authority && Drone)
{
// Destroy the drone first, if exists.
DestroyDrone();
FRotator actorRotation(GetActorRotation());
FVector actorLocation(GetActorLocation() + actorRotation.Vector() * 200.0f);
FTransform SpawnTransform(actorRotation, actorLocation);
UE_LOG(LogDebug, VeryVerbose, TEXT("AKPlayerCharacter::LocalSpawnDrone - GetActorRotation=%s GetActorLocation=%s"), *GetActorRotation().ToString(), *actorLocation.ToString());
AKDroneCharacter* CreatedDrone = GetWorld()->SpawnActorDeferred<AKDroneCharacter>(Drone, SpawnTransform, this);
if (CreatedDrone)
{
// Enable the collision
CreatedDrone->SetActorEnableCollision(true);
// Set the instigator
CreatedDrone->Instigator = Instigator;
// Set the our controller as a master
CreatedDrone->MasterController = Cast<AKPlayerController>(Controller);
UE_LOG(LogDebug, VeryVerbose, TEXT("AKPlayerCharacter::LocalSpawnDrone - CreatedDrone=%s CreatedDrone->Instigator=%s CreatedDrone->MasterController=%s"), *GetNameSafe(CreatedDrone), *GetNameSafe(CreatedDrone->Instigator), *GetNameSafe(CreatedDrone->MasterController));
FActorSpawnParameters SpawnInfo;
SpawnInfo.Instigator = CreatedDrone;
SpawnInfo.ObjectFlags |= RF_Transient; // We never want to save player controllers into a map
AKDroneCharacterController* NewPC = GetWorld()->SpawnActor<AKDroneCharacterController>(AKDroneCharacterController::StaticClass(), actorLocation, actorRotation, SpawnInfo);
if (NewPC)
{
// Complete the spawing
UGameplayStatics::FinishSpawningActor(CreatedDrone, SpawnTransform);
NewPC->Possess(CreatedDrone);
// Assign it once created to avoid replication too soon
SpawnedDrone = CreatedDrone;
NewPC->SetPawnFromRep(SpawnedDrone);
}
}
}
}
void AKPlayerCharacter::DestroyDrone()
{
UE_LOG(LogDebug, Verbose, TEXT("AKPlayerCharacter::DestroyDrone - Role=%s Actor=%s SpawnedDrone=%s IsLocallyControlled=%i"), NETROLETOSTRING(Role), *GetName(), *GetNameSafe(SpawnedDrone), IsLocallyControlled());
// If we are not on the server, do nothing
if (Role < ROLE_Authority)
{
return;
}
if (SpawnedDrone)
{
SpawnedDrone->Destroy();
SpawnedDrone = nullptr;
}
}
void AKPlayerCharacter::DroneMoveForward(float Value)
{
if ((SpawnedDrone != nullptr) && (Value != 0.0f))
{
UE_LOG(LogDebug, VeryVerbose, TEXT("AKPlayerCharacter::DroneMoveForward - Value=%f SpawnedDrone=%s"), Value, *GetNameSafe(SpawnedDrone));
SpawnedDrone->DroneMoveForward(Value);
}
}
void AKPlayerCharacter::DroneTurnAtRate(float Rate)
{
if ((SpawnedDrone != NULL) && (Rate != 0.0f))
{
UE_LOG(LogDebug, VeryVerbose, TEXT("AKPlayerCharacter::DroneTurnAtRate - Rate=%f SpawnedDrone=%s"), Rate, *GetNameSafe(SpawnedDrone));
SpawnedDrone->DroneTurnAtRate(Rate);
}
}
void AKPlayerCharacter::DroneMoveRight(float Value)
{
if ((SpawnedDrone != nullptr) && (Value != 0.0f))
{
UE_LOG(LogDebug, VeryVerbose, TEXT("AKPlayerCharacter::DroneMoveRight - Value=%f SpawnedDrone=%s"), Value, *GetNameSafe(SpawnedDrone));
SpawnedDrone->DroneMoveRight(Value);
}
}
void AKPlayerCharacter::DroneMoveUp(float Value)
{
if (SpawnedDrone != nullptr && (Value != 0.0f))
{
UE_LOG(LogDebug, VeryVerbose, TEXT("AKPlayerCharacter::DroneMoveUp - Value=%f SpawnedDrone=%s"), Value, *GetNameSafe(SpawnedDrone));
SpawnedDrone->DroneMoveUp(Value);
}
}
If I check the log on the server and the client, one strange this is that the OnRep_Pawn() functions isn’t called on client for the drone. It is called for the Player’s character.
On the client side, I have warning messages:
LogNetPlayerMovement: Warning: CreateSavedMove: Hit limit of 96 saved moves (timing out or very bad ping?)
On the sever side, I have warning messages:
[2018.10.18-14.16.49:079][ 9]LogNetPlayerMovement: TimeStamp expired. 20.774586, CurrentTimeStamp: 20.774586
[2018.10.18-14.16.49:348][ 25]LogNetPlayerMovement: TimeStamp expired. 21.035360, CurrentTimeStamp: 21.053251
[2018.10.18-14.16.49:382][ 27]LogNetPlayerMovement: TimeStamp expired. 21.035360, CurrentTimeStamp: 21.087803
[2018.10.18-14.16.49:415][ 29]LogNetPlayerMovement: TimeStamp expired. 21.035360, CurrentTimeStamp: 21.122499
Log on the server side:
[2018.10.18-14.16.28:093][ 12]LogGameState: Match State Changed from PlayerIntro to CountdownToBegin
[2018.10.18-14.16.28:098][ 12]LogDebug: Verbose: AKBaseCharacter::PostInitializeComponents - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:108][ 12]LogDebug: Verbose: AKPlayerController::SetPawn Role=ROLE_Authority IsLocalPlayerController()=0 InPawn=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:119][ 12]LogDebug: AKPlayerController::Possess PawnToPossess=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:130][ 12]LogDebug: Verbose: AKBaseCharacter::PossessedBy - this=BP_PlayerCharacter_C_0 NewController=KPlayerController_1
[2018.10.18-14.16.28:141][ 12]LogDebug: Verbose: AKPlayerController::SetPawn Role=ROLE_Authority IsLocalPlayerController()=0 InPawn=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:152][ 12]LogDebug: Verbose: AKPlayerCharacter::Restart - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:163][ 12]LogDebug: Verbose: AKBaseCharacter::Restart - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:176][ 12]LogDebug: Verbose: AKBaseCharacter::PostInitializeComponents - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_1
[2018.10.18-14.16.28:185][ 12]LogDebug: Verbose: AKPlayerController::SetPawn Role=ROLE_Authority IsLocalPlayerController()=0 InPawn=BP_PlayerCharacter_C_1
[2018.10.18-14.16.28:196][ 12]LogDebug: AKPlayerController::Possess PawnToPossess=BP_PlayerCharacter_C_1
[2018.10.18-14.16.28:207][ 12]LogDebug: Verbose: AKBaseCharacter::PossessedBy - this=BP_PlayerCharacter_C_1 NewController=KPlayerController_2
[2018.10.18-14.16.28:218][ 12]LogDebug: Verbose: AKPlayerController::SetPawn Role=ROLE_Authority IsLocalPlayerController()=0 InPawn=BP_PlayerCharacter_C_1
[2018.10.18-14.16.28:229][ 12]LogDebug: Verbose: AKPlayerCharacter::Restart - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_1
[2018.10.18-14.16.28:240][ 12]LogDebug: Verbose: AKBaseCharacter::Restart - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_1
[2018.10.18-14.16.28:251][ 12]LogGameMode: AKGameMode::UpdatePlayersPresence - MatchState=CountdownToBegin
[2018.10.18-14.16.28:361][ 14]LogNetPackageMap: Warning: Long net serialize: 60.949299ms, Serialized Object None
[2018.10.18-14.16.28:515][ 14]LogNetPackageMap: Warning: Long net serialize: 22.566002ms, Serialized Object None
[2018.10.18-14.16.30:361][ 14]LogDebug: Verbose: AKBaseCharacter::ServerSpawnDrone_Implementation - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_1
[2018.10.18-14.16.30:372][ 14]LogDebug: Verbose: AKBaseCharacter::LocalSpawnDrone - Role=ROLE_Authority IsLocallyControlled=0
[2018.10.18-14.16.30:383][ 14]LogDebug: VeryVerbose: AKPlayerCharacter::LocalSpawnDrone - Drone=BP_Drone_C
[2018.10.18-14.16.30:394][ 14]LogDebug: Verbose: AKPlayerCharacter::DestroyDrone - Role=ROLE_Authority Actor=BP_PlayerCharacter_C_1 SpawnedDrone=None IsLocallyControlled=0
[2018.10.18-14.16.30:405][ 14]LogDebug: VeryVerbose: AKPlayerCharacter::LocalSpawnDrone - GetActorRotation=P=0.000000 Y=90.000114 R=0.000000 GetActorLocation=X=-15485.000 Y=-54050.000 Z=462.063
[2018.10.18-14.16.30:416][ 14]LogDebug: VeryVerbose: AKPlayerCharacter::LocalSpawnDrone - CreatedDrone=BP_Drone_C_0 CreatedDrone->Instigator=BP_PlayerCharacter_C_1 CreatedDrone->MasterController=KPlayerController_2
[2018.10.18-14.16.30:427][ 14]LogDebug: Verbose: AKDroneCharacter::PostInitializeComponents - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_Drone_C_0
[2018.10.18-14.16.30:438][ 14]LogOnline: AKDroneCharacterController::Possess - this=KDroneCharacterController_0 InPawn()=BP_Drone_C_0
[2018.10.18-14.16.30:449][ 14]LogDebug: Verbose: AKDroneCharacter::PossessedBy - this=BP_Drone_C_0 NewController=KDroneCharacterController_0
[2018.10.18-14.16.30:460][ 14]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_0 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_0
[2018.10.18-14.16.30:471][ 14]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_0 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_0
[2018.10.18-14.16.30:482][ 14]LogDebug: Verbose: AKDroneCharacter::Restart - Role=ROLE_Authority IsLocallyControlled=1 Actor=BP_Drone_C_0
[2018.10.18-14.16.30:493][ 14]LogOnline: AKDroneCharacterController::OnRep_Pawn - this=KDroneCharacterController_0 GetPawn()=BP_Drone_C_0
[2018.10.18-14.16.30:504][ 14]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_0 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_0
[2018.10.18-14.16.32:172][ 14]LogDebug: Verbose: AKBaseCharacter::ServerSpawnDrone_Implementation - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_0
[2018.10.18-14.16.32:183][ 14]LogDebug: Verbose: AKBaseCharacter::LocalSpawnDrone - Role=ROLE_Authority IsLocallyControlled=0
[2018.10.18-14.16.32:194][ 14]LogDebug: VeryVerbose: AKPlayerCharacter::LocalSpawnDrone - Drone=BP_Drone_C
[2018.10.18-14.16.32:205][ 14]LogDebug: Verbose: AKPlayerCharacter::DestroyDrone - Role=ROLE_Authority Actor=BP_PlayerCharacter_C_0 SpawnedDrone=None IsLocallyControlled=0
[2018.10.18-14.16.32:216][ 14]LogDebug: VeryVerbose: AKPlayerCharacter::LocalSpawnDrone - GetActorRotation=P=0.000000 Y=-90.000183 R=0.000000 GetActorLocation=X=-0.001 Y=11350.000 Z=462.063
[2018.10.18-14.16.32:227][ 14]LogDebug: VeryVerbose: AKPlayerCharacter::LocalSpawnDrone - CreatedDrone=BP_Drone_C_1 CreatedDrone->Instigator=BP_PlayerCharacter_C_0 CreatedDrone->MasterController=KPlayerController_1
[2018.10.18-14.16.32:238][ 14]LogDebug: Verbose: AKDroneCharacter::PostInitializeComponents - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_Drone_C_1
[2018.10.18-14.16.32:249][ 14]LogOnline: AKDroneCharacterController::Possess - this=KDroneCharacterController_1 InPawn()=BP_Drone_C_1
[2018.10.18-14.16.32:260][ 14]LogDebug: Verbose: AKDroneCharacter::PossessedBy - this=BP_Drone_C_1 NewController=KDroneCharacterController_1
[2018.10.18-14.16.32:271][ 14]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_1 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_1
[2018.10.18-14.16.32:282][ 14]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_1 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_1
[2018.10.18-14.16.32:293][ 14]LogDebug: Verbose: AKDroneCharacter::Restart - Role=ROLE_Authority IsLocallyControlled=1 Actor=BP_Drone_C_1
[2018.10.18-14.16.32:304][ 14]LogOnline: AKDroneCharacterController::OnRep_Pawn - this=KDroneCharacterController_1 GetPawn()=BP_Drone_C_1
[2018.10.18-14.16.32:315][ 14]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_1 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_1
Log on one client side (we have two clients connected to the game 1vs1):
[2018.10.18-14.16.28:272][126]LogDebug: Verbose: AKBaseCharacter::PostInitializeComponents - Role=ROLE_SimulatedProxy IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:272][126]LogOnline: AKPlayerController::OnRep_Pawn - GetPawn()=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:272][126]LogDebug: Verbose: AKPlayerController::SetPawn Role=ROLE_AutonomousProxy IsLocalPlayerController()=1 InPawn=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:273][126]LogDebug: Verbose: AKPlayerController::SetPawn Role=ROLE_AutonomousProxy IsLocalPlayerController()=1 InPawn=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:273][126]LogDebug: Verbose: AKPlayerController::SetPawn Role=ROLE_AutonomousProxy IsLocalPlayerController()=1 InPawn=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:273][126]LogDebug: Verbose: AKPlayerCharacter::Restart - Role=ROLE_AutonomousProxy IsLocallyControlled=1 Actor=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:273][126]LogDebug: Verbose: AKBaseCharacter::Restart - Role=ROLE_AutonomousProxy IsLocallyControlled=1 Actor=BP_PlayerCharacter_C_0
[2018.10.18-14.16.28:273][126]LogDebug: Verbose: AKBaseCharacter::SpawnEquipmentSlots - Role=ROLE_AutonomousProxy IsLocallyControlled=1
[2018.10.18-14.16.28:273][126]LogDebug: Verbose: AKPlayerCharacter::SpawnDrone - Role=ROLE_AutonomousProxy IsLocallyControlled=1
[2018.10.18-14.16.31:384][316]LogNetPlayerMovement: Warning: CreateSavedMove: Hit limit of 96 saved moves (timing out or very bad ping?)
[2018.10.18-14.16.32:383][378]LogOnline: AKPlayerController::OnRep_Pawn - GetPawn()=BP_PlayerCharacter_C_0
[2018.10.18-14.16.32:384][378]LogDebug: Verbose: AKPlayerController::SetPawn Role=ROLE_AutonomousProxy IsLocalPlayerController()=1 InPawn=BP_PlayerCharacter_C_0
[2018.10.18-14.16.32:385][378]LogDebug: Verbose: AKDroneCharacter::PostInitializeComponents - Role=ROLE_SimulatedProxy IsLocallyControlled=0 Actor=BP_Drone_C_0
[2018.10.18-14.16.32:388][378]LogDebug: Verbose: AKBaseCharacter::PostInitializeComponents - Role=ROLE_SimulatedProxy IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_1
[2018.10.18-14.16.32:391][378]LogDebug: Verbose: AKDroneCharacter::PostInitializeComponents - Role=ROLE_SimulatedProxy IsLocallyControlled=0 Actor=BP_Drone_C_1
[2018.10.18-14.16.32:410][378]LogDebug: Verbose: AKPlayerCharacter::OnRep_SpawnedDrone - Role=ROLE_SimulatedProxy IsLocallyControlled=0 SpawnedDrone=BP_Drone_C_1
[2018.10.18-14.16.33:399][428]LogDebug: Verbose: AKTeamPlayerHUD::InitializePlayerForMatch
[2018.10.18-14.16.33:399][428]LogDebug: Verbose: SKInGameMenuWidget::OnInitializePlayerForMatch
[2018.10.18-14.16.33:407][428]LogDebug: Verbose: SKActionBarWidget::RegenerateBottomLeftRow - InGame=1
[2018.10.18-14.16.33:407][428]LogDebug: Verbose: SKActionBarWidget::RegenerateBottomLeftRow - ThePawn=BP_PlayerCharacter_C_0 ThePawn->GetLeftHandWeapon()=BasicWeaponBlunt_C_0
[2018.10.18-14.16.33:407][428]LogDebug: Verbose: SKActionBarWidget::RegenerateBottomLeftRow - UID=000062 CurrentLeftWeaponUID=000062
[2018.10.18-14.16.33:407][428]LogDebug: Verbose: SKActionBarWidget::RegenerateBottomRightRow - InGame=1
[2018.10.18-14.16.33:407][428]LogDebug: Verbose: SKActionBarWidget::RegenerateBottomRightRow - ThePawn=BP_PlayerCharacter_C_0 ThePawn->GetRightHandWeapon()=BasicWeaponAxe_C_0
[2018.10.18-14.16.33:407][428]LogDebug: Verbose: SKActionBarWidget::RegenerateBottomRightRow - UID=000296 CurrentRightWeaponUID=000296
[2018.10.18-14.16.43:322][969]LogDebug: VeryVerbose: AKPlayerCharacter::DroneMoveForward - Value=1.000000 SpawnedDrone=BP_Drone_C_0
[2018.10.18-14.16.43:322][969]LogDebug: VeryVerbose: AKDroneCharacter::DroneMoveForward - Value=1.000000
[2018.10.18-14.16.43:339][970]LogDebug: VeryVerbose: AKPlayerCharacter::DroneMoveForward - Value=1.000000 SpawnedDrone=BP_Drone_C_0
[2018.10.18-14.16.43:339][970]LogDebug: VeryVerbose: AKDroneCharacter::DroneMoveForward - Value=1.000000
[2018.10.18-14.16.43:356][971]LogDebug: VeryVerbose: AKPlayerCharacter::DroneMoveForward - Value=1.000000 SpawnedDrone=BP_Drone_C_0
[2018.10.18-14.16.43:356][971]LogDebug: VeryVerbose: AKDroneCharacter::DroneMoveForward - Value=1.000000
[2018.10.18-14.16.43:375][972]LogDebug: VeryVerbose: AKPlayerCharacter::DroneMoveForward - Value=1.000000 SpawnedDrone=BP_Drone_C_0
[2018.10.18-14.16.43:375][972]LogDebug: VeryVerbose: AKDroneCharacter::DroneMoveForward - Value=1.000000
[2018.10.18-14.16.43:393][973]LogDebug: VeryVerbose: AKPlayerCharacter::DroneMoveForward - Value=1.000000 SpawnedDrone=BP_Drone_C_0
[2018.10.18-14.16.43:393][973]LogDebug: VeryVerbose: AKDroneCharacter::DroneMoveForward - Value=1.000000
As I can see on the client side, the Pawn of the player is replicated on the client.
LogOnline: AKPlayerController::OnRep_Pawn - GetPawn()=BP_PlayerCharacter_C_0
But for the drone’s pawn I don’t see the OnRep_Pawn call on the client.
And very strange the OnRep_Pawn is called on the server
LogOnline: AKDroneCharacterController::OnRep_Pawn - this=KDroneCharacterController_0 GetPawn()=BP_Drone_C_0
In addition, I’ve made one change.
I removed the call NewPC->SetPawnFromRep(SpawnedDrone); from LocalSpawnDrone function in character.
Now In the server log I can notice one strange thing that can explain the replication problem.
[2018.10.19-07.59.17:994][682]LogGameState: Match State Changed from PlayerIntro to CountdownToBegin
[2018.10.19-07.59.18:005][682]LogKSGMDebug: Verbose: AKBaseCharacter::PostInitializeComponents - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_0
[2018.10.19-07.59.18:015][682]LogKSGMDebug: Verbose: AKPlayerController::SetPawn Role=ROLE_Authority IsLocalPlayerController()=0 InPawn=BP_PlayerCharacter_C_0
[2018.10.19-07.59.18:025][682]LogKSGMDebug: AKPlayerController::Possess PawnToPossess=BP_PlayerCharacter_C_0
[2018.10.19-07.59.18:036][682]LogKSGMDebug: Verbose: AKBaseCharacter::PossessedBy - this=BP_PlayerCharacter_C_0 NewController=KPlayerController_0
[2018.10.19-07.59.18:047][682]LogKSGMDebug: Verbose: AKPlayerController::SetPawn Role=ROLE_Authority IsLocalPlayerController()=0 InPawn=BP_PlayerCharacter_C_0
[2018.10.19-07.59.18:058][682]LogKSGMDebug: Verbose: AKPlayerCharacter::Restart - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_0
[2018.10.19-07.59.18:069][682]LogKSGMDebug: Verbose: AKBaseCharacter::Restart - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_0
[2018.10.19-07.59.18:082][682]LogKSGMDebug: Verbose: AKBaseCharacter::PostInitializeComponents - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_1
[2018.10.19-07.59.18:091][682]LogKSGMDebug: Verbose: AKPlayerController::SetPawn Role=ROLE_Authority IsLocalPlayerController()=0 InPawn=BP_PlayerCharacter_C_1
[2018.10.19-07.59.18:102][682]LogKSGMDebug: AKPlayerController::Possess PawnToPossess=BP_PlayerCharacter_C_1
[2018.10.19-07.59.18:113][682]LogKSGMDebug: Verbose: AKBaseCharacter::PossessedBy - this=BP_PlayerCharacter_C_1 NewController=KPlayerController_1
[2018.10.19-07.59.18:124][682]LogKSGMDebug: Verbose: AKPlayerController::SetPawn Role=ROLE_Authority IsLocalPlayerController()=0 InPawn=BP_PlayerCharacter_C_1
[2018.10.19-07.59.18:135][682]LogKSGMDebug: Verbose: AKPlayerCharacter::Restart - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_1
[2018.10.19-07.59.18:146][682]LogKSGMDebug: Verbose: AKBaseCharacter::Restart - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_1
[2018.10.19-07.59.18:157][682]LogGameMode: AKGameMode::UpdatePlayersPresence - MatchState=CountdownToBegin
[2018.10.19-07.59.18:728][684]LogKSGMDebug: Verbose: AKBaseCharacter::ServerSpawnDrone_Implementation - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_1
[2018.10.19-07.59.18:737][684]LogKSGMDebug: Verbose: AKBaseCharacter::LocalSpawnDrone - Role=ROLE_Authority IsLocallyControlled=0
[2018.10.19-07.59.18:748][684]LogKSGMDebug: VeryVerbose: AKPlayerCharacter::LocalSpawnDrone - Drone=BP_Drone_C
[2018.10.19-07.59.18:759][684]LogKSGMDebug: Verbose: AKPlayerCharacter::DestroyDrone - Role=ROLE_Authority Actor=BP_PlayerCharacter_C_1 SpawnedDrone=None IsLocallyControlled=0
[2018.10.19-07.59.18:769][684]LogKSGMDebug: VeryVerbose: AKPlayerCharacter::LocalSpawnDrone - GetActorRotation=P=0.000000 Y=90.000114 R=0.000000 GetActorLocation=X=-15485.000 Y=-54050.000 Z=462.063
[2018.10.19-07.59.18:780][684]LogKSGMDebug: VeryVerbose: AKPlayerCharacter::LocalSpawnDrone - CreatedDrone=BP_Drone_C_0 CreatedDrone->Instigator=BP_PlayerCharacter_C_1 CreatedDrone->MasterController=KPlayerController_1
[2018.10.19-07.59.18:791][684]LogKSGMDebug: Verbose: AKDroneCharacter::PostInitializeComponents - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_Drone_C_0
[2018.10.19-07.59.18:802][684]LogOnline: AKDroneCharacterController::Possess - this=KDroneCharacterController_0 InPawn()=BP_Drone_C_0
[2018.10.19-07.59.18:813][684]LogKSGMDebug: Verbose: AKDroneCharacter::PossessedBy - this=BP_Drone_C_0 NewController=KDroneCharacterController_0
[2018.10.19-07.59.18:824][684]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_0 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_0
[2018.10.19-07.59.18:835][684]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_0 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_0
[2018.10.19-07.59.18:846][684]LogKSGMDebug: Verbose: AKDroneCharacter::Restart - Role=ROLE_Authority IsLocallyControlled=1 Actor=BP_Drone_C_0
[2018.10.19-07.59.18:888][686]LogKSGMDebug: Verbose: AKBaseCharacter::ServerSpawnDrone_Implementation - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_PlayerCharacter_C_0
[2018.10.19-07.59.18:890][686]LogKSGMDebug: Verbose: AKBaseCharacter::LocalSpawnDrone - Role=ROLE_Authority IsLocallyControlled=0
[2018.10.19-07.59.18:901][686]LogKSGMDebug: VeryVerbose: AKPlayerCharacter::LocalSpawnDrone - Drone=BP_Drone_C
[2018.10.19-07.59.18:912][686]LogKSGMDebug: Verbose: AKPlayerCharacter::DestroyDrone - Role=ROLE_Authority Actor=BP_PlayerCharacter_C_0 SpawnedDrone=None IsLocallyControlled=0
[2018.10.19-07.59.18:923][686]LogKSGMDebug: VeryVerbose: AKPlayerCharacter::LocalSpawnDrone - GetActorRotation=P=0.000000 Y=-90.000183 R=0.000000 GetActorLocation=X=-0.001 Y=11350.000 Z=462.063
[2018.10.19-07.59.18:935][686]LogKSGMDebug: VeryVerbose: AKPlayerCharacter::LocalSpawnDrone - CreatedDrone=BP_Drone_C_1 CreatedDrone->Instigator=BP_PlayerCharacter_C_0 CreatedDrone->MasterController=KPlayerController_0
[2018.10.19-07.59.18:945][686]LogKSGMDebug: Verbose: AKDroneCharacter::PostInitializeComponents - Role=ROLE_Authority IsLocallyControlled=0 Actor=BP_Drone_C_1
[2018.10.19-07.59.18:956][686]LogOnline: AKDroneCharacterController::Possess - this=KDroneCharacterController_1 InPawn()=BP_Drone_C_1
[2018.10.19-07.59.18:967][686]LogKSGMDebug: Verbose: AKDroneCharacter::PossessedBy - this=BP_Drone_C_1 NewController=KDroneCharacterController_1
[2018.10.19-07.59.18:978][686]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_1 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_1
[2018.10.19-07.59.18:989][686]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_1 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_1
[2018.10.19-07.59.19:000][686]LogKSGMDebug: Verbose: AKDroneCharacter::Restart - Role=ROLE_Authority IsLocallyControlled=1 Actor=BP_Drone_C_1
The problem is that the drone spawn on the server is local controlled.
[2018.10.19-07.59.18:824][684]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_0 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_0
[2018.10.19-07.59.18:835][684]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_0 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_0
[2018.10.19-07.59.18:978][686]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_1 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_1
[2018.10.19-07.59.18:989][686]LogOnline: AKDroneCharacterController::SetPawn this=KDroneCharacterController_1 Role=ROLE_Authority IsLocalController()=1 InPawn=BP_Drone_C_1
For the player’s character, it is not locally controlled on the server, but on the client.
Why the drone spawned on the server is set as locally controlled ?
Someone has an idea on what’s going on ?