Announcement

Collapse
No announcement yet.

AimOffset Pitch in multiplayer

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

    #16
    I had the same issue.

    Here's how I fixed it with just blueprint:
    https://answers.unrealengine.com/que...plicating.html

    Comment


      #17
      Originally posted by Zak Middleton View Post
      Thanks for reporting this!

      Would it be sufficient to expose GetBaseAimRotation() to BPs as a BP callable func?

      Also I think the check in the current engine code for using RemoteViewPitch only if the Pawn's current pitch is zero is suspicious, I'll probably remove that.
      Yes, I think exposing GetBaseAimRotation() would be great. Otherwise it's a pretty big hassle just to get the pitch through BP. Thank you!

      Comment


        #18
        Originally posted by letoast View Post
        Yes, I think exposing GetBaseAimRotation() would be great. Otherwise it's a pretty big hassle just to get the pitch through BP. Thank you!
        Cool, I already checked in a change on 8/7 to expose it to BPs. Thanks for the feedback!
        Zak Middleton
        Sr. Engine Programmer, Epic Games

        Comment


          #19
          Thank you! Do you know by chance when these kinds of updates/changes get pushed to usable(official?) releases? Like when will I be able to use this(or other updates)?

          Comment


            #20
            Originally posted by letoast View Post
            Thank you! Do you know by chance when these kinds of updates/changes get pushed to usable(official?) releases? Like when will I be able to use this(or other updates)?
            This missed the timeframe for 4.4 which was just released, so it will be in 4.5. Not sure when that will be. In the meantime I would rely on the other options presented in this thread.

            If you're using GitHub source then changes are pushed the same day.
            Zak Middleton
            Sr. Engine Programmer, Epic Games

            Comment


              #21
              Oh, ok, thanks. I just thought that it might be in an intermediate update(like 4.3.1 or 4.2.1)

              Comment


                #22
                Here is the solution for C++ multiplayer, but please help and describe the math, I would really appreciate that!

                Code:
                void ACPP_1Character::Tick(float DeltaTime)
                {
                    Super::Tick(DeltaTime);
                    if (!IsLocallyControlled()) {
                        FRotator NewRot = FirstPersonCameraComponent->RelativeRotation;
                        NewRot.Pitch = (uint8)RemoteViewPitch * 360.f / 255.f; // to compress to 1 byte [edited to help others]
                
                        FirstPersonCameraComponent->SetRelativeRotation(NewRot);
                    }
                }

                But please explain me why do use this math
                RemoteViewPitch * 360.f / 255.f;
                And if I am right this one:
                IsLocallyControlled()
                , is used to not do for you character, because you do not need it, and it is already happening or not?

                I only catch on 360°(degrees), and 255 is the limitation of uint8

                Why is RemoteViewPitch is 255 only instaed of 360 (to save some memory or what?)
                Last edited by EminentEIement; 01-24-2020, 08:40 AM.

                Comment


                  #23
                  Originally posted by EminentEIement View Post
                  Why is RemoteViewPitch is 255 only instaed of 360 (to save some memory or what?)
                  RemoteViewPitch is replicated in a byte (0-255) to save on replication bandwidth (though this is less of a concern these days). This code looks like it says for non-local characters, you need to set the rotation of the camera, and you do that by remapping the byte to a 360 degree value. Reorder the statement to ((float)RemoteViewPitch / 255.f) * 360.f and it might make more sense. Map to (0..1), then scale to (0..360).

                  See APawn::GetBaseAimRotation() and APawn::SetRemoteViewPitch().
                  Zak Middleton
                  Sr. Engine Programmer, Epic Games

                  Comment


                    #24
                    Hello Zak,

                    Thank you so much for your answer and the other posts!

                    One more Solution(with your help):
                    Code:
                    void ACPP_1Character::Tick(float DeltaTime)
                    {
                        Super::Tick(DeltaTime);
                        if (!IsLocallyControlled()) {
                            FRotator NewRot = FirstPersonCameraComponent->RelativeRotation;
                            NewRot.Pitch = (float)(GetBaseAimRotation().Pitch);
                    
                            FirstPersonCameraComponent->SetRelativeRotation(NewRot);
                        }
                    }


                    I have found your replies in this post, which was really helpful to get more into this topic:
                    URL link to the post: Serious shot replication problem [video] with more info about ViewPitch +
                    GetBaseAimRotation


                    [QUESTION 1]
                    How is the clients' pitch is replicated?

                    But could you please clarify a bit about how the replication is done( I have read the post above, but that does not suffice for me to get how it works)?
                    So e.g.
                    I used next construction:
                    Code:
                    if(Role == ROLE_Authority) { // some actions which you need to replicate(run on server and tell your clients) }
                    My assumption(guesswork) is that character pawn is already replicated, so if I set any values it must be replicated? (if it is correct, then why the yaw is replicated but the pitch does not)?


                    [QUESTION 2]
                    One more thing I would like to know:
                    Why the yaw is already being replicated by default, but the pitch is not? (Sorry if I misread somewhere and did not notice this)
                    I do appreciate any help, and I ready to help others if I can
                    Best regards,
                    Roman!
                    Last edited by EminentEIement; 01-24-2020, 09:38 AM.

                    Comment


                      #25
                      Replication happens for Actors by looking at what properties to replicate, given by GetLifetimeReplicatedProps(). Pawn marks RemoteViewPitch as Replicated in its UPROPERTY definition and says to replicate it in the mentioned function to everyone but the owner (COND_SkipOwner, because they sent the value to the server already).

                      Normally Actors replicate their complete actor rotation if they are set to replicate, and this is the case for Pawns as well. However for Pawns/Characters we usually don't tilt the capsule upward, but they do spin around horizontally on the vertical axis. However we still want to know which way they are looking/aiming, so RemoteViewPitch is replicated additionally as a variable on the Pawn. If this setup didn't work well for a specific project, an alternative would be to replicate your own variable(s) that replicated more of what you need, like all of ControlRotation etc.
                      Zak Middleton
                      Sr. Engine Programmer, Epic Games

                      Comment


                        #26
                        Thank you, Sir, again!

                        I do appreciate you help!

                        I have already fiddle with GetLifetimeReplicatedProps() a bit.

                        Please, if you have some free time take a glance at my new [url: question] – (Solved [I have derived from the wrong class])
                        Last edited by EminentEIement; 01-27-2020, 07:43 AM.

                        Comment


                          #27
                          Could someone please explain or direct where I can find what have I done wrong?
                          Pitch replication works just fine if I Set 2 players(server and client can see each other pitch rotation), but if I run it as a standalone game it does not work...

                          this code it run
                          Code:
                          // Called every frame
                          void ASCharacter::Tick(float DeltaTime)
                          if (!IsLocallyControlled()) { // even if i try it like this: if (!IsLocallyControlled() || Role == ROLE_Authority)
                                  if (FPPCameraComp->IsActive()) {
                                      FRotator NewRot = FPPCameraComp->RelativeRotation;
                                      NewRot.Pitch = (uint8)RemoteViewPitch * 360.f / 255.f; // to compress to 1 byte [edited to help others]
                                      Pitch = NewRot.Pitch;
                                      FPPCameraComp->SetRelativeRotation(NewRot);
                                  }
                                  else if (CameraComp->IsActive()) {
                                      FRotator NewRot = CameraComp->RelativeRotation;
                                      NewRot.Pitch = (float)(GetBaseAimRotation().Pitch);
                                      Pitch = NewRot.Pitch;
                                      CameraComp->SetRelativeRotation(NewRot);
                                  }
                              }
                          }
                          ScreenShots:
                           
                          Spoiler


                          My AnimBP "Pitch" value is set to Replicated
                          https://blueprintue.com/blueprint/tel-lry-/

                          I greatly appreciate your help!
                          Last edited by EminentEIement; 03-16-2020, 12:14 PM.

                          Comment

                          Working...
                          X