Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RWTH VR Toolkit
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LuFG VR VIS
VR-Group
Unreal-Development
Plugins
RWTH VR Toolkit
Commits
743f6114
Commit
743f6114
authored
1 year ago
by
David Gilbert
Browse files
Options
Downloads
Patches
Plain Diff
fix(pawn, replication): Fixes DC Sync Parent Component interfering with multiplayer.
parent
d0c248c5
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp
+30
-17
30 additions, 17 deletions
Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp
Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h
+4
-0
4 additions, 0 deletions
Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h
with
34 additions
and
17 deletions
Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp
+
30
−
17
View file @
743f6114
...
...
@@ -41,21 +41,7 @@ ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) : Super(Ob
LeftHand
=
CreateDefaultSubobject
<
UReplicatedMotionControllerComponent
>
(
TEXT
(
"Left Hand MCC"
));
LeftHand
->
SetupAttachment
(
RootComponent
);
}
void
ARWTHVRPawn
::
BeginPlay
()
{
Super
::
BeginPlay
();
#if PLATFORM_SUPPORTS_CLUSTER
// Add an nDisplay Parent Sync Component. It syncs the parent's transform from master to clients.
// This is required because for collision based movement, it can happen that the physics engine
// for some reason acts different on the nodes, therefore leading to a potential desync when
// e.g. colliding with an object while moving.
SyncComponent
=
Cast
<
USceneComponent
>
(
AddComponentByClass
(
UDisplayClusterSceneComponentSyncParent
::
StaticClass
(),
false
,
FTransform
::
Identity
,
false
));
AddInstanceComponent
(
SyncComponent
);
#endif
}
void
ARWTHVRPawn
::
BeginPlay
()
{
Super
::
BeginPlay
();
}
void
ARWTHVRPawn
::
Tick
(
float
DeltaSeconds
)
{
...
...
@@ -79,26 +65,32 @@ void ARWTHVRPawn::NotifyControllerChanged()
{
Super
::
NotifyControllerChanged
();
UE_LOG
(
Toolkit
,
Display
,
TEXT
(
"ARWTHVRPawn: Player Controller has changed, trying to change DCRA attachment if possible..."
));
// 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
();
}
}
...
...
@@ -247,6 +239,24 @@ void ARWTHVRPawn::UpdateRightHandForDesktopInteraction() const
}
}
void
ARWTHVRPawn
::
MulticastAddDCSyncComponent_Implementation
()
{
#if PLATFORM_SUPPORTS_CLUSTER
// Add an nDisplay Parent Sync Component. It syncs the parent's transform from master to clients.
// This is required because for collision based movement, it can happen that the physics engine
// for some reason acts different on the nodes, therefore leading to a potential desync when
// e.g. colliding with an object while moving.
if
(
URWTHVRUtilities
::
IsRoomMountedMode
())
{
SyncComponent
=
Cast
<
USceneComponent
>
(
AddComponentByClass
(
UDisplayClusterSceneComponentSyncParent
::
StaticClass
(),
false
,
FTransform
::
Identity
,
false
));
AddInstanceComponent
(
SyncComponent
);
UE_LOGFMT
(
Toolkit
,
Display
,
"RWTHVRPawn: Added Sync Component to pawn {Pawn}"
,
GetName
());
}
#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.
// It is only executed on the server because attachments are synced to all clients, but not from client to server.
...
...
@@ -274,6 +284,9 @@ void ARWTHVRPawn::AttachDCRAtoPawn()
UE_LOGFMT
(
Toolkit
,
Warning
,
"No CaveSetup Actor found which can be attached to the Pawn! This won't work on the Cave."
);
}
if
(
HasAuthority
())
// Should always be the case here, but double check
MulticastAddDCSyncComponent
();
}
void
ARWTHVRPawn
::
SetupMotionControllerSources
()
...
...
This diff is collapsed.
Click to expand it.
Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h
+
4
−
0
View file @
743f6114
...
...
@@ -107,6 +107,10 @@ protected:
UFUNCTION
(
Reliable
,
Server
)
void
ServerAttachDCRAtoPawnRpc
();
/* Add a sync component to all instances of this pawn */
UFUNCTION
(
Reliable
,
NetMulticast
)
void
MulticastAddDCSyncComponent
();
/* Attaches the DCRA to the pawn */
void
AttachDCRAtoPawn
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment