Announcement

Collapse
No announcement yet.

Motion controllers and networking

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #46
    Issue persists in 4.15

    Comment


      #47
      if just motion controller positions , you can use UDP messaging to broadcast to other player ,without using the replication.

      Comment


        #48
        stag beetle, How would you insure the position was for the same pawn on the server, replication seems to do it for you?

        Anyway, 4.17 has the same problem mirroring controllers, is this still an issue in 4.19?

        Comment


          #49
          Hi guys. I got the same issue and I managed to fix it in quite simple way.
          First I did some research and I found many threads about the same problem. I post them at the end of the post so you can make some additional reading if you want to.

          So in UMotionControllerComponent inside the PollControllerState method there is an authority check...
          Code:
            
          if (IsInGameThread())
          {
               // Cache state from the game thread for use on the render thread
               const AActor* MyOwner = GetOwner();
               const APawn* MyPawn = Cast<APawn>(MyOwner);
               bHasAuthority = MyPawn ? MyPawn->IsLocallyControlled() : (MyOwner->Role == ENetRole::ROLE_Authority);
          }
          
          if (bHasAuthority)
              {
                  TArray<IMotionController*> MotionControllers = IModularFeatures::Get().GetModularFeatureImplementations<IMotionController>(IMotionController::GetModularFeatureName());
                  for (auto MotionController : MotionControllers)
                  {.....
          Authority check in here is not enough because what we do later is telling the engine to get all motion controllers out there and process them. So if one of them got authority you still update them all.
          PollControllerState is a private method so you cannot edit definition of that method. So instead I wrote this piece of code inside the TickComponent in my UMotionControllerComponent derived class


          Code:
          void UNetworkMotionControllerComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
          {
              Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
              const AActor* MyOwner = GetOwner();
              const APawn* MyPawn = Cast<APawn>(MyOwner);
              bHasAuthority = MyPawn ? MyPawn->IsLocallyControlled() : throw;
              if (bHasAuthority == false)
              {
                  SetAssociatedPlayerIndex(-1);
          // this line is where we tell the engine to not to use this controller. PlayerIndex variable is used differently in platform specific places. eg. SteamVR uses some 2 dimensional array to store the controllers and then only checks if they are smaller than the max value so it can be a better solution to set it to maximum value of int instead. You have to check it up with your platform. (-1 works well with oculus rift and htc vive)
              }
          
              if (bIsActive&&PlayerIndex == 0)
              {
                  FVector Position;
                  FRotator Orientation;
                  float WorldToMeters = GetWorld() ? GetWorld()->GetWorldSettings()->WorldToMeters : 100.0f;
                  const bool bNewTrackedState = PollControllerState(Position, Orientation, WorldToMeters);
                  if (bNewTrackedState)
                  {
                      Server_SetRelativeLocationAndRotation(Position, Orientation);
                      //SetRelativeLocationAndRotation(Position, Orientation);
                  }
          //rest of the default motioncontrollercomponent's code
          So basically you have to do those things:
          1. set PlayerIndex != 0 on the controllers that should't get the data from you motion controller.
          2. implement the function that will set the position and rotation. It have to be done on server so the other clients can see it. I copied the code from USceneComponent::SetRelativeLocationAndRotation() and it woks like a charm.

          Please keep in mind that this is the working solution but its like alpha alpha version. I'm sure I'll try to optimize this so I don't have to do all those casting inside of a tick function and get rid of the throwing exceptions when there is no Pawn. Do not use this as ready to go solution in your projects. I posted this only as a reference so you can get on going with your projects if you stucked.


          Links to read if you want to get more information:

          https://forums.unrealengine.com/deve...and-networking
          https://forums.unrealengine.com/deve...r-multi-player
          https://answers.unrealengine.com/que...s-them-al.html
          https://forums.unrealengine.com/deve...nd-networking=
          https://www.youtube.com/watch?v=jVdFpuicptQ at 14:35
          and the thread about this livestream
          https://forums.unrealengine.com/unre...epic-hq?99586=

          Comment


            #50
            Originally posted by S_Q_R View Post
            Hi guys. I got the same issue and I managed to fix it in quite simple way.
            First I did some research and I found many threads about the same problem. I post them at the end of the post so you can make some additional reading if you want to.

            I have an open source full implementation of replicating the controllers with a set Htz and smoothing already if it saves you some time.

            Most of it is in the TickComponent function of my controller subclass.
            https://bitbucket.org/mordentral/vre...rComponent.cpp

            The struct that is uses for the actual replication is in another header file, it has a lot of optimizations for the replicated data.
            Last edited by mordentral; 10-25-2018, 11:39 AM.


            Consider supporting me on patreon

            My Open source tools and plugins
            Advanced Sessions Plugin
            VR Expansion Plugin

            Comment


              #51
              Hi, I need some help on this subject, can't quite understand the blueprint workaround, can someone assist me? =(

              Comment


                #52
                Hello,

                I'm trying to create local LAN VR Multiplayer where both players are using VR Headset (VIVE)

                I'm using the VR Template From EPIC

                First of all, I want to ask if the motion controller template is capable of LAN Multiplayer straight out of the box? Is it normal to face such problems like these I will describe below?

                1. The problem is when the client joins the Host, the host doesn't see the client motion controller hands.
                The client can call RPC's and both of the players can see the result.

                2. Also, the Client can't teleport using the navmesh, but the server can.
                3. On Spawn the Client receives an additional pair of skeletal hands attached to his left hand.

                Does anybody have a clue how I can fix that?

                Comment


                  #53
                  Originally posted by MosPetrov View Post
                  Hello,

                  I'm trying to create local LAN VR Multiplayer where both players are using VR Headset (VIVE)

                  I'm using the VR Template From EPIC

                  First of all, I want to ask if the motion controller template is capable of LAN Multiplayer straight out of the box? Is it normal to face such problems like these I will describe below?

                  1. The problem is when the client joins the Host, the host doesn't see the client motion controller hands.
                  The client can call RPC's and both of the players can see the result.

                  2. Also, the Client can't teleport using the navmesh, but the server can.
                  3. On Spawn the Client receives an additional pair of skeletal hands attached to his left hand.

                  Does anybody have a clue how I can fix that?
                  ​​​​​​​Have you found a solution to 3)?

                  For 2) you have to go into the project settings and there into the nav system tab and there set "allow client navigation".
                  For 1) I am new too, but the motion controller locations and orientations are imo entirely client side (see this thread for a solution).

                  The VR Template is just for singleplayer (speaking as of version 4.24).



                  Comment


                    #54
                    As of engine version 4.24 there does not seem to be a "Get Hand Position and Orientation" node anymore. Anyone knows alternative nodes?

                    Comment

                    Working...
                    X