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"

Pawn owners in multiplayer (c++)

I have two questions:

  1. I want to know who is the owner ,or how to determine it, of the pawn that is spawned when a player joins a session.

  2. How to set the owner of an actor. I know that you have to use SetOwner() but which actor do you actually pass to this function.

I need this so i can call a server RPC from a client. From my tests so far it seems that the pawn spawned when a player joins is owned by the server or is unowned and thus calling a server RPC from a client is dropped.

alt text

Product Version: UE 4.21
Tags:
table.png (15.2 kB)
more ▼

asked Apr 13 '19 at 02:18 PM in C++ Programming

avatar image

Zveroth
1

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

2 answers: sort voted first

I think you are mixing owner and controller

How controlling pawns and net communication in unreal works is over controllers. A player has a playercontroller and with that player controller he can posses a pawn to steer it.

If you have a pawn you can call GetController() on it to find out if anyone steers it. If you have a controller you can call GetPawn() to get the controlled pawn.

You have to be a little bit careful in multiplayer games only the server has playercontrollers for all players, the individual clients have only their own playercontroller.

RPC come in three flavours NetMulticast: from server to all clients Client: from server to the client who is controlling the actor Server: from client to server, (can only be called on actors controlled by the client making the call)

Additionally you can check the ownership of an actor by testing its net role. actor->GetLocalRole()

Results: ROLE_SimulatedProxy ..... You are on a client and the server has total control over it ROLE_AutonomousProxy ... You are on a client and you are able to call rpc server calls on it ROLE_Authority ..... You are on the server with total control

more ▼

answered Apr 14 '19 at 12:08 AM

avatar image

Lardo Deepdelver
956 6 4 6

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

Ownership is who is own the client connection. It looks into the outer class of your pawn. Usually it finishes with Controller. Controller is created on clients. So client own the pawn

Ownership and authority is different.

Authority is who created the object ( normally server )

From my tests so far it seems that the pawn spawned when a player joins is owned by the server

This assumption is wrong. Pawn is not owned by server. Server has authority over it. Pawn owner by client who own the network connection cite from http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf

PlayerController is the first Class that thePlayer actually 'owns', but what does that mean? Each Conn> ection has a PlayerController, created specifically for that Connection. A PlayerController,that is created for that reason, is owned by that Connection. So when we determine ifan Actor is owned by someone, we actually query up to the mostouter Owner and if thisis a PlayerController, then the Connection that owns the PlayerController also owns that Actor.

more ▼

answered May 09 '19 at 10:47 AM

avatar image

denton85
11 1 4 5

(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