Announcement

Collapse
No announcement yet.

AimOffset Pitch in multiplayer

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

    AimOffset Pitch in multiplayer

    Hi everyone!

    I have set up the aim offset for my character and it works nicely on the client that controls the character. However, if I look at the character from a different client, the aim offset isn't working. It's as if the Pitch isn't being picked up by the other client. Screenshot for better clarification:
    Attached Files
    Last edited by letoast; 07-20-2014, 02:08 PM.

    #2
    Bump. Anyone?

    Comment


      #3
      Ok, so I think I've found out why this doesn't work in my case with multiplayer, but it does in ShooterGame example.

      ShooterGame example uses a c++ function that is exposed to BP. It's code uses a function called GetBaseAimRotation(), which has in it's definition this:
      https://docs.unrealengine.com/latest...ion/index.html
      Code:
          // If we have no controller, we simply use our rotation
          POVRot = GetActorRotation();
       
          // If our Pitch is 0, then use RemoteViewPitch
          if( POVRot.Pitch == 0.f )
          {
              POVRot.Pitch = RemoteViewPitch;
              POVRot.Pitch = POVRot.Pitch * 360.f/255.f;
          }
       
          return POVRot;
      Note RemoteViewPitch! RemoteViewPitch is a replicated property(?), which is: "Replicated so we can see where remote clients are looking."
      https://docs.unrealengine.com/latest...tch/index.html

      In other words: there is no simple way of getting(afaik) the view rotation of remote clients using BP, which I need to offset the aim of the character on the other client....

      Epic, could you expose this property to BP please?

      Comment


        #4
        Ok, so to close this problem, I finally solved it by using C++, by extending the Character class and reparenting my BP Character class to the new C++ extended Character class, to which I only added the GetAimOffsets function from ShooterGame's character class.
        The code for it is(in MyCharacter2.cpp):
        Code:
        FRotator AMyCharacter2::GetAimOffsets() const
        {
        	const FVector AimDirWS = GetBaseAimRotation().Vector();
        	const FVector AimDirLS = ActorToWorld().InverseTransformVectorNoScale(AimDirWS);
        	const FRotator AimRotLS = AimDirLS.Rotation();
        
        	return AimRotLS;
        }
        and in MyCharacter2.h:
        Code:
        	UFUNCTION(BlueprintCallable, Category = "Game|Weapon")
        	FRotator GetAimOffsets() const;
        so that I can use it as a node.

        And now everything works as it should:
        Attached Files

        Comment


          #5
          I stumbled over the exactly same problem and tried solving it the same way.. only that it still doesn't work. My GetBaseAimRotation returns 0 for Pitch :/

          Comment


            #6
            Further fiddling around showed: It works for only one instance (probably the server one) if I switch off the dedicated server option.
            Last edited by Marenz; 07-27-2014, 08:35 AM.

            Comment


              #7
              I'm making a blueprint only game, and while I could go into C++ to fix this, I'd rather not.

              @Epic, Any chance we could get this set up so it works in a similar fashion for the BP-only case?
              Storyteller - An immersive VR audiobook player

              Dungeon Survival - WIP First person dungeon crawler with a focus on survival and environmental gameplay ala roguelikes

              Comment


                #8
                Bump. Also created a question in the answer hub: https://answers.unrealengine.com/que...ways-zero.html

                Comment


                  #9
                  Did you use the exact same function that I posted or did you just try to get the RemoteViewPitch property?

                  Comment


                    #10
                    Originally posted by n00854180t View Post
                    I'm making a blueprint only game, and while I could go into C++ to fix this, I'd rather not.

                    @Epic, Any chance we could get this set up so it works in a similar fashion for the BP-only case?
                    I'm also interested in this. I'm building an open community blueprint only project.

                    Thanks!

                    Metahusk: A 501(c)(3) Creative Development Cooperative
                    Projects | Forums | Repositories | Nonprofit | Donate

                    Comment


                      #11
                      Used the exact same function, also copied from the ShooterGame

                      Comment


                        #12
                        Originally posted by Marenz View Post
                        Used the exact same function, also copied from the ShooterGame
                        Hmmmm, weird. I can send you my project if you want to check what's different in your/my attempt

                        Comment


                          #13
                          I solved it. We were overriding Tick and didn't call the super function which would set the RemotePitchView. Darn. Thanks for the offers and tips!

                          Comment


                            #14
                            No problem! I'm glad that I opened this thread so that people can see that there are still quite some things that blueprints don't have access to and also how to solve this relatively important issue when it comes to multuplayer

                            Comment


                              #15
                              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.
                              Zak Middleton
                              Sr. Engine Programmer, Epic Games

                              Comment

                              Working...
                              X