Download

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:

Bump. Anyone?

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:


    // 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/INT/API/Runtime/Engine/GameFramework/APawn/RemoteViewPitch/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?

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):


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:


	UFUNCTION(BlueprintCallable, Category = "Game|Weapon")
	FRotator GetAimOffsets() const;

so that I can use it as a node.

And now everything works as it should:

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 :confused:

Further fiddling around showed: It works for only one instance (probably the server one) if I switch off the dedicated server option.

1 Like

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?

Bump. Also created a question in the answer hub: RemoteViewPitch is always zero - UE4 AnswerHub

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

I’m also interested in this. I’m building an open community blueprint only project.

Thanks!

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

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!

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

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.

I had the same issue.

Here’s how I fixed it with just blueprint:
https://answers.unrealengine.com/questions/45916/aimoffset-not-replicating.html

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!

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.