How do I possess an actor in multiplayer?

Hello,

I’m making a Prop Hunt game for Christmas and I want to possess my Prop character when I press a key.

In solo-mode it works but when I try to do it in multiplayer-mode, it works on the server but it is not replicated on the client-side.

How can I do that ?

PS: I already know that the Possess node is a server only action.

Any help would be appreciated :slight_smile:

What do you mean it is not replicated?
Possession only happens on the server (as you mentioned). What are you expecting to happen and what is actually happening?

Hello, you don’t need to put “Urgent”, no one will answer faster.

You need to show us a screen of the blueprint if you want some help.

Hi,
So I have two characters named “Hunter” and “Prop” as you can see and I want when I press the Tab key the Hunter (who is the default pawn class) to switch to the Prop character.
On the server side the change is well done but when it is the client who presses the key, the Prop Character is created but nothing happens, he doesn’t possess him !

(I’m a french teenager so my english is not perfect and I tried as much as possible to well explain)

323720-characters.png


323710-

So according to you screenshot,

it should be “run on server”, and not “run on owning clients”.

323742-sans-titre7.png

The reason behind this is possessing can be only call from the server (autorithy) to avoid cheating (imagine if you can posses the player of someone else).

Here, you execute on Owning client, that mean you want to run the function on the owning client but :
a) Like multicast, this is only allowed to be run from the server
b) There is no owner on the moment, and when there is no owner, the owner is the server (by default).

Don’t panic, i’m french too, and you’re english is probably better than mine :slight_smile:

Aherys_ answer is correct. Just to add further to this.

You are getting confused with the editor window listed as “Server”. What you are seeing is NOT the server.

You are running a listen server, which means the first client creates the server, however the window itself is showing the client’s view for that server. So you are seeing it working in that window believing it is the server, where actually, you’re just seeing a client the same as the other window.

Follow Aherys_ advice, make sure your actors are set to replicate correctly and you should be good to go.

Also, logs are your friend! Keep an eye on the output log and you will clearly see where things are executing and you will probably see some messages directing you to the problem.

Good luck.

Alex

Thank you for your quick response !

So, I modified my blueprint-script and made my event “OwningClientEventPossess” run on the server, but it still doesn’t work :confused:

If you know how to fix this can you maybe show me please ? I’m a noobi beginner… xD

Oh you’re a frenchman too ? That’s cool ! :stuck_out_tongue:

Thank you very much Alex for helping me on this subject, I’m starting to understand the principle better ! :slight_smile:

probably the get player controller, remember they are not the same from each instance of the game.

But just print who is the owner ship as @alekaan01 said, you can see better where is the trouble here.
Or always attach a screen of you’r blueprint, so we can see if you did a mistake.

I understand your explanations but I don’t know how to apply them, for example where should I put the “Authority” node etc …

I am very new to multiplayer :confused:

Unfortunally, you need to follow some course about multiplayer networking before going into it =)

I think too, thank you for your help and have a good evening !
If I solve my problem I’ll let you know ! :slight_smile:

I’m stock here…

Hi FlashTexxx

As Aherys_ and myself have mentioned. The possession MUST happen on the server.
In that screenshot, you are firing a server event, which then fires a client event that then tries to possess the pawn.

I also see you are trying to do this in the character class. It is better practice for the PlayerController to handle the possession.

Good luck.

Alex

I finally found it ! It works !!!

I finally figured out what to do and where my mistake was,
I will put the screenshots here for those who have the same question.

So, just checked if the sender is the server
or the client and then call the “possess” function
for each of them on the server !

I could never have understood this without
your help @Alekann01, @Aherys_ so thank you sooo much :))

1 Like

Congratulatio :slight_smile:

Glad you fix it !

i know it is a late reply but i will write this for anyone in the future

I found an easy solution just run the possess node on server event

I don’t know much about multiplayer, can you explain a little more?

Yoo Thank you so much, this is the only solution that works ! <3