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

Set player state variable to hmd/desktop when pawn input is set up. Not the...

Set player state variable to hmd/desktop when pawn input is set up. Not the best place to put this but will do for now.
parent 90491a74
Branches
No related tags found
1 merge request!31Initial Pawn Replication
...@@ -33,7 +33,7 @@ FString ARWTHVRGameModeBase::InitNewPlayer(APlayerController* NewPlayerControlle ...@@ -33,7 +33,7 @@ FString ARWTHVRGameModeBase::InitNewPlayer(APlayerController* NewPlayerControlle
: PrimaryNodeId; : PrimaryNodeId;
const EPlayerType Type = NodeName == PrimaryNodeId ? EPlayerType::nDisplayPrimary : EPlayerType::nDisplaySecondary; const EPlayerType Type = NodeName == PrimaryNodeId ? EPlayerType::nDisplayPrimary : EPlayerType::nDisplaySecondary;
State->SetPlayerType(Type); State->RequestSetPlayerType(Type);
} }
} }
......
...@@ -47,8 +47,25 @@ void ARWTHVRPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& O ...@@ -47,8 +47,25 @@ void ARWTHVRPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& O
DOREPLIFETIME_WITH_PARAMS_FAST(ARWTHVRPlayerState, PlayerType, SharedParams); DOREPLIFETIME_WITH_PARAMS_FAST(ARWTHVRPlayerState, PlayerType, SharedParams);
} }
void ARWTHVRPlayerState::SetPlayerTypeServerRpc_Implementation(const EPlayerType NewPlayerType)
{
SetPlayerType(NewPlayerType);
}
void ARWTHVRPlayerState::SetPlayerType(const EPlayerType NewPlayerType) void ARWTHVRPlayerState::SetPlayerType(const EPlayerType NewPlayerType)
{ {
MARK_PROPERTY_DIRTY_FROM_NAME(ARWTHVRPlayerState, PlayerType, this); MARK_PROPERTY_DIRTY_FROM_NAME(ARWTHVRPlayerState, PlayerType, this);
PlayerType = NewPlayerType; PlayerType = NewPlayerType;
} }
void ARWTHVRPlayerState::RequestSetPlayerType(const EPlayerType NewPlayerType)
{
if (HasAuthority())
{
SetPlayerType(NewPlayerType);
}
else
{
SetPlayerTypeServerRpc(NewPlayerType);
}
}
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "GameFramework/PlayerController.h" #include "GameFramework/PlayerController.h"
#include "EnhancedInputComponent.h" #include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h" #include "EnhancedInputSubsystems.h"
#include "Core/RWTHVRPlayerState.h"
#include "Pawn/ContinuousMovementComponent.h" #include "Pawn/ContinuousMovementComponent.h"
#include "Pawn/ReplicatedCameraComponent.h" #include "Pawn/ReplicatedCameraComponent.h"
#include "Pawn/ReplicatedMotionControllerComponent.h" #include "Pawn/ReplicatedMotionControllerComponent.h"
...@@ -74,12 +75,24 @@ void AVirtualRealityPawn::SetupPlayerInputComponent(UInputComponent* PlayerInput ...@@ -74,12 +75,24 @@ void AVirtualRealityPawn::SetupPlayerInputComponent(UInputComponent* PlayerInput
return; return;
} }
EPlayerType Type = EPlayerType::Desktop;
if (UVirtualRealityUtilities::IsDesktopMode()) if (UVirtualRealityUtilities::IsDesktopMode())
{ {
PlayerController->bShowMouseCursor = true; PlayerController->bShowMouseCursor = true;
PlayerController->bEnableClickEvents = true; PlayerController->bEnableClickEvents = true;
PlayerController->bEnableMouseOverEvents = true; PlayerController->bEnableMouseOverEvents = true;
} }
else if (UVirtualRealityUtilities::IsHeadMountedMode())
{
Type = EPlayerType::HMD;
}
// Should not do this here but on connection or on possess I think.
ARWTHVRPlayerState* State = GetPlayerState<ARWTHVRPlayerState>();
if (State)
{
State->RequestSetPlayerType(Type);
}
InputSubsystem->ClearAllMappings(); InputSubsystem->ClearAllMappings();
......
...@@ -22,6 +22,11 @@ private: ...@@ -22,6 +22,11 @@ private:
UPROPERTY(Replicated, Category=PlayerState, BlueprintGetter=GetPlayerType, meta=(AllowPrivateAccess)) UPROPERTY(Replicated, Category=PlayerState, BlueprintGetter=GetPlayerType, meta=(AllowPrivateAccess))
EPlayerType PlayerType = EPlayerType::Desktop; EPlayerType PlayerType = EPlayerType::Desktop;
UFUNCTION(Reliable, Server)
void SetPlayerTypeServerRpc(EPlayerType NewPlayerType);
void SetPlayerType(EPlayerType NewPlayerType);
public: public:
UFUNCTION(BlueprintGetter) UFUNCTION(BlueprintGetter)
...@@ -30,7 +35,8 @@ public: ...@@ -30,7 +35,8 @@ public:
return PlayerType; return PlayerType;
} }
void SetPlayerType(EPlayerType NewType); UFUNCTION(BlueprintCallable)
void RequestSetPlayerType(EPlayerType NewPlayerType);
virtual void CopyProperties(APlayerState* PlayerState) override; virtual void CopyProperties(APlayerState* PlayerState) override;
virtual void OverrideWith(APlayerState* PlayerState) override; virtual void OverrideWith(APlayerState* PlayerState) override;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment