Skip to content
Snippets Groups Projects
Commit 965a3f01 authored by David Gilbert's avatar David Gilbert :bug:
Browse files

refactor(replication, pawn): Removes leftover code from DCRA attachment process.

parent dc683d38
No related branches found
No related tags found
1 merge request!93feature(replication, pawn): Adds (initial) different way to attach DCRA to...
Pipeline #432551 failed
...@@ -65,14 +65,12 @@ void ARWTHVRPawn::NotifyControllerChanged() ...@@ -65,14 +65,12 @@ void ARWTHVRPawn::NotifyControllerChanged()
{ {
Super::NotifyControllerChanged(); Super::NotifyControllerChanged();
UE_LOG(Toolkit, Display,
TEXT("ARWTHVRPawn: Player Controller has changed, trying to change DCRA attachment if possible..."));
// Try and use PlayerType for this: // Try and use PlayerType for this:
if (HasAuthority()) if (HasAuthority())
{ {
UE_LOG(Toolkit, Display,
TEXT("ARWTHVRPawn: Player Controller has changed, trying to change DCRA attachment if possible..."));
if (const ARWTHVRPlayerState* State = GetPlayerState<ARWTHVRPlayerState>()) if (const ARWTHVRPlayerState* State = GetPlayerState<ARWTHVRPlayerState>())
{ {
const EPlayerType Type = State->GetPlayerType(); const EPlayerType Type = State->GetPlayerType();
...@@ -86,37 +84,6 @@ void ARWTHVRPawn::NotifyControllerChanged() ...@@ -86,37 +84,6 @@ void ARWTHVRPawn::NotifyControllerChanged()
} }
} }
} }
/*
// Only do this for all local controlled pawns
if (IsLocallyControlled())
{
UE_LOG(Toolkit, Display,
TEXT("ARWTHVRPawn: Player Controller has changed for local pawn, trying to change DCRA attachment if "
"possible..."));
// Only do this for the primary node or when we're running in standalone
if (URWTHVRUtilities::IsRoomMountedMode() &&
(URWTHVRUtilities::IsPrimaryNode() || GetNetMode() == NM_Standalone))
{
UE_LOG(Toolkit, Display,
TEXT("ARWTHVRPawn: We're the primary node, we want the DCRA attached to our pawn."));
// If we are also the authority (standalone or listen server), directly attach it to us.
// If we are not (client), ask the server to do it.
if (HasAuthority())
{
UE_LOG(Toolkit, Display, TEXT("ARWTHVRPawn: We have authority, do the attachment."));
AttachDCRAtoPawn();
}
else
{
UE_LOG(Toolkit, Display, TEXT("ARWTHVRPawn: We don't have authority, ask the sercer to attach."));
ServerAttachDCRAtoPawnRpc();
}
}
}
*/
} }
void ARWTHVRPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) void ARWTHVRPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
...@@ -132,7 +99,8 @@ void ARWTHVRPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponen ...@@ -132,7 +99,8 @@ void ARWTHVRPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponen
return; return;
} }
UE_LOGFMT(Toolkit, Display, "SetupPlayerInputComponent: Player Controller is valid, setting up input for {Pawn}", GetName()); UE_LOGFMT(Toolkit, Display, "SetupPlayerInputComponent: Player Controller is valid, setting up input for {Pawn}",
GetName());
// Set the control rotation of the PC to zero again. There is a small period of 2 frames where, when the pawn gets // Set the control rotation of the PC to zero again. There is a small period of 2 frames where, when the pawn gets
...@@ -283,7 +251,6 @@ void ARWTHVRPawn::MulticastAddDCSyncComponent_Implementation() ...@@ -283,7 +251,6 @@ void ARWTHVRPawn::MulticastAddDCSyncComponent_Implementation()
#endif #endif
} }
// Todo rewrite this in some other way or attach it differently, this is horrible
// Executed on the server only: Finds and attaches the CaveSetup Actor, which contains the DCRA to the Pawn. // Executed on the server only: Finds and attaches the CaveSetup Actor, which contains the DCRA to the Pawn.
// It is only executed on the server because attachments are synced to all clients, but not from client to server. // It is only executed on the server because attachments are synced to all clients, but not from client to server.
void ARWTHVRPawn::AttachDCRAtoPawn() void ARWTHVRPawn::AttachDCRAtoPawn()
...@@ -335,13 +302,6 @@ void ARWTHVRPawn::SetupMotionControllerSources() ...@@ -335,13 +302,6 @@ void ARWTHVRPawn::SetupMotionControllerSources()
RightHand->SetTrackingMotionSource(MotionControllerSourceRight); RightHand->SetTrackingMotionSource(MotionControllerSourceRight);
} }
// Requests the server to perform the attachment, as only the server can sync this to all the other clients.
void ARWTHVRPawn::ServerAttachDCRAtoPawnRpc_Implementation()
{
// We're on the server here - attach the actor to the pawn.
AttachDCRAtoPawn();
}
void ARWTHVRPawn::SetCameraOffset() const void ARWTHVRPawn::SetCameraOffset() const
{ {
// this also incorporates the BaseEyeHeight, if set as static offset, // this also incorporates the BaseEyeHeight, if set as static offset,
......
...@@ -103,10 +103,6 @@ protected: ...@@ -103,10 +103,6 @@ protected:
/* Replicated functionality */ /* Replicated functionality */
/* Ask the server to attach the DCRA to the correct pawn */
UFUNCTION(Reliable, Server)
void ServerAttachDCRAtoPawnRpc();
/* Add a sync component to all instances of this pawn */ /* Add a sync component to all instances of this pawn */
UFUNCTION(Reliable, NetMulticast) UFUNCTION(Reliable, NetMulticast)
void MulticastAddDCSyncComponent(); void MulticastAddDCSyncComponent();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment