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"

[Closed] more than one player in multiplayer controlling a pawn

It's a simple pawn; only slides on one axis.

Before I even start; is this even possible?

I got it working for one player; using onClicked/Released in the level BP. I'm going to give it a shot in multiplayer now.

Product Version: Not Selected
Tags:
more ▼

asked Mar 09 '15 at 04:10 PM in Blueprint Scripting

avatar image

shgs_sls
110 8 11 14

avatar image Shadowriver Mar 09 '15 at 05:04 PM

It's definitly possible one way or another. Did you tried possessing same pawn with secound Player Controller?

avatar image shgs_sls Mar 09 '15 at 05:14 PM

Not yet; I'm using getController, where the target is pawn. There is not a parameter for index?

I'm going to see what else can be done.

It seems like I might just have to repossess the pawn every time a player clicks on it.

avatar image shgs_sls Mar 09 '15 at 07:58 PM

Alright; I haven't been able to get it to work.

I tried finding documentation on the possess function, the first thing I found was this: https://docs.unrealengine.com/latest/INT/Gameplay/Framework/Pawn/index.html

It says there's a one-to-one relationship between the controller and pawn.

What's your way, because if it works that is fantastic. Otherwise it would seem each player will have to wait to use the pawn.

I'm going to keep on trying to find more documentation on how it actually works.

edit: I just looked at the cpp and it's definitely 1-1. I'm trying to avoid rewriting Possess; but it would seem I have to.

avatar image ZombieKemist Mar 09 '15 at 09:27 PM

So I managed to put together something that works for this. Instead of attempting to possess the same pawn with multiple controllers I used an input event in the controller to trigger pawn movement. You can call a custom event within the pawn (I called it Clicked) that passes the Player Controller that clicked on it. You can then check within the Pawn if the Controller is the Pawn's or not and alter the behavior accordingly. In order to get it to work in multiplayer I had to use a variety of Server/Client events. Basically, I had to have two events within the player controller. The first was the input event (left mouse button in this case), that called the Server event, which passed the controller to the pawn. The Pawn event ran on the server, but used two Multicast events, one for if it was clicked by the owning controller (Clicked By Owner), and one if it was not (Clicked By Other). It's a little complex, but it saves rewriting Possess!

avatar image Daniele Faggion Jul 14 '15 at 07:14 PM

Hi ZombieKemist I'm tryin to follow your instructions, but it's not clear to me how you have routed the control through the events you're talkin about. Please can you post some code (or blueprint) or also a simple schema with pseudo-code to explain this better? Thanks!

avatar image ZombieKemist Jul 14 '15 at 08:40 PM

I don't have access to the engine right now to put together the blueprint, but I can try to make my process more clear. If it's still unclear I can post the blueprint at a later date.

I started with the object I wanted to be clicked, which would be the player's pawn. That pawn got a PlayerController blueprint (which, by definition, is unique for each player).

In the controller: I used an input event for the left mouse click to check for a pawn being clicked. You can use the GetObjectUnderCursor, or something like that to determine what was clicked (I don't have the blueprint in front of me right now). From that I called the server event in the controller. For the server event, I just had it call the server side event in the pawn that was clicked, passing itself as the controller value.

In the pawn: I made a custom server event called Clicked, which took as input the Controller that clicked on it. I then checked whether the Controller that caused the clicking was the same as the pawn's own controller. If the controller that clicked on it was the pawn's controller, I called the multicast ClickedBySelf event. If it wasn't, I called the multicast ClickedByOther. You can put your specific actions in those events, depending on what you want to do. The multicast makes sure to run everything on both server side and client side.

I hope that clears things up a bit, but let me know if it doesn't!

avatar image Daniele Faggion Jul 15 '15 at 01:24 AM

First of all thanks. this clears things up a bit of course, but my case is different, probably you can help me : What if I want to control the player character on client A (the server host on a listen server) to move exactly as the player character B (on a second client)? I've tried to adapt your method (I don't need to discern between bySelf or byOther because I want to perform the same action) but what I cannot get working is effectively move the first as the second, they still move separately, when the second client receive an input I move it and call an event on the server which pass the player controller (player index 0 because in this case I want the server-host A to be moved from the client B), from there I apply the same movement to the controller passed, but this make it only be updated on both client and server as usual, if A is moved then I can see it on client B and viceversa, I'm missing how to make B (or A) moves both characters on all clients (ie: make player 1 be a pawn controlled directly by player 2). What do you suggest in this case?

avatar image Daniele Faggion Jul 15 '15 at 02:48 AM

Nevermind, I found a solution looking carefully to your setup, at the same way I just had to call a RPC on server if I doesn't have authority as client, and pass to it the current controller, so on server side I could know what controller is requiring the update on the target client pawn (set by default in my case when the level begin), then the server RPC perform the movement/actions on the target pawn itself. Thanks, your recipe helped me to figure it out!

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

The question has been closed Jun 02 '15 at 05:45 PM by shgs_sls for the following reason:

The question is answered, right answer was accepted


2 answers: sort voted first

Follow this question

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

Answers to this question