A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
VRPlayerController.cpp
Go to the documentation of this file.
1// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2
4#include "AI/NavigationSystemBase.h"
6#include "Engine/Player.h"
7//#include "Runtime/Engine/Private/EnginePrivate.h"
8
9
10AVRPlayerController::AVRPlayerController(const FObjectInitializer& ObjectInitializer)
11 : Super(ObjectInitializer)
12{
14}
15
17{
18 Super::SpawnPlayerCameraManager();
19
20 // Turn off the default FOV and position replication of the camera manager, most functions should be sending values anyway and I am replicating
21 // the actual camera position myself so this is just wasted bandwidth
22 if(PlayerCameraManager != NULL && bDisableServerUpdateCamera)
23 PlayerCameraManager->bUseClientSideCameraUpdates = false;
24}
25
26// #TODO 4.20: This was removed
27/*void AVRPlayerController::InitNavigationControl(UPathFollowingComponent*& PathFollowingComp)
28{
29 PathFollowingComp = FindComponentByClass<UPathFollowingComponent>();
30 if (PathFollowingComp == NULL)
31 {
32 PathFollowingComp = NewObject<UVRPathFollowingComponent>(this);
33 PathFollowingComp->RegisterComponentWithWorld(GetWorld());
34 PathFollowingComp->Initialize();
35 }
36}*/
37
38/*IPathFollowingAgentInterface* AVRPlayerController::GetPathFollowingAgent() const
39{
40 // Moved spawning the path following component into the path finding logic instead
41 return FNavigationSystem::FindPathFollowingAgentForActor(*this);
42}*/
43
45{
46
47 // #TODO: Should I be only doing this if ticking CMC and CMC is active?
48 if (AVRBaseCharacter * VRChar = Cast<AVRBaseCharacter>(GetPawn()))
49 {
50 // Keep from calling multiple times
51 UVRBaseCharacterMovementComponent * BaseCMC = Cast<UVRBaseCharacterMovementComponent>(VRChar->GetMovementComponent());
52
53 if (!BaseCMC || !BaseCMC->bRunControlRotationInMovementComponent)
54 return Super::PlayerTick(DeltaTime);
55
56 if (!bShortConnectTimeOut)
57 {
58 bShortConnectTimeOut = true;
59 ServerShortTimeout();
60 }
61
62 TickPlayerInput(DeltaTime, DeltaTime == 0.f);
63 LastRotationInput = RotationInput;
64
65 if ((Player != NULL) && (Player->PlayerController == this))
66 {
67 // Validate current state
68 bool bUpdateRotation = false;
69 if (IsInState(NAME_Playing))
70 {
71 if (GetPawn() == NULL)
72 {
73 ChangeState(NAME_Inactive);
74 }
75 else if (Player && GetPawn() == AcknowledgedPawn && (!BaseCMC || (BaseCMC && !BaseCMC->IsActive())))
76 {
77 bUpdateRotation = true;
78 }
79 }
80
81 if (IsInState(NAME_Inactive))
82 {
83 if (GetLocalRole() < ROLE_Authority)
84 {
85 SafeServerCheckClientPossession();
86 }
87
88 //bUpdateRotation = !IsFrozen();
89 }
90 else if (IsInState(NAME_Spectating))
91 {
92 if (GetLocalRole() < ROLE_Authority)
93 {
94 SafeServerUpdateSpectatorState();
95 }
96
97 // Keep it when spectating
98 bUpdateRotation = true;
99 }
100
101 // Update rotation
102 if (bUpdateRotation)
103 {
104 UpdateRotation(DeltaTime);
105 }
106 }
107 }
108 else
109 {
110 // Not our character, forget it
111 Super::PlayerTick(DeltaTime);
112 }
113}
114
115UVRLocalPlayer::UVRLocalPlayer(const FObjectInitializer& ObjectInitializer)
116 : Super(ObjectInitializer)
117{
118}
virtual void PlayerTick(float DeltaTime) override
virtual void SpawnPlayerCameraManager() override
bool bDisableServerUpdateCamera
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRPlayerController")
AVRPlayerController(const FObjectInitializer &ObjectInitializer=FObjectInitializer::Get())
bool bRunControlRotationInMovementComponent
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRMovement")