x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

PlayerController, Possess, Replication

Hi,

I try to move the player specifics stuff to my PlayerController, but I have some trouble.

After possessing a pawn, I should be able to add and initialize a widget (through a blueprint call) and set a camera.

First, I tried this:

 void AMyPlayerController::Possess(APawn* aPawn)
 {
     APlayerController::Possess(aPawn);
     FollowCamera->AttachTo(OwnedShCharacter->GetCameraBoom(), USpringArmComponent::SocketName);
     FollowCamera->bUsePawnControlRotation = false;
     SetViewTarget(this);
     BPAfterPossessEvent();
 }

(OwnedShCharacter is initialized at BeginPlayingState(), which is called before APlayerController::Possess() ends.)

But the client will never run the Possess function at all. I also tried BeginPlayingState(). It did not have a valid character reference there.

I could not find a function which would be called on client after the effect of the Possession is replicated - it has to have a valid reference to the character in order to setup things. Is there any function like that?

Thanks for reading,

Elathan

Product Version: UE 4.8
Tags:
more ▼

asked Jun 17 '15 at 10:37 PM in C++ Programming

avatar image

Elathan
431 25 29 61

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Call it manually. Create PC function like APlayerController::Client_Possess with UFUNCTION(Client) flag and call it inside Possess func on server.

more ▼

answered Jun 18 '15 at 04:51 AM

avatar image

Detech
461 13 7 28

avatar image Elathan Jun 18 '15 at 05:52 AM

Thanks for the answer!

Unfortunately it will be called before the result of the possessing is replicated to the client - I don't know why, but GetPawn() still doesn't give a good result on client side :(

avatar image Detech Jun 18 '15 at 08:57 AM
avatar image Elathan Jun 18 '15 at 05:06 PM

Thanks, it worked :)

However I also had to set bAutoManageActiveCameraTarget to false in the constructor of my PlayerController, cause otherwise SetViewTarget() was called on the local controller after OnRep_Pawn() (with the possessed pawn).

Both the camera and the widget works now on both server and client side.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question