Multiplayer game - Move 4 players in different location

Hello everyone,

I’m working on a turn-based game and I coded in blueprint function to select a player state from an array of player controller to select the player that I want, but I’m blocking on the movement.

For context :
Game mode > I’m using the OnPostLogin to create an array of Player controller when player join the game
Game State > I dupplicate the array from the game mode, from this local array, I get the first one for example and get the player state. Then, I’m setting it to a variable set to RepNotify

For information, I had help from this previous topic :

Then, I tried to send this selected controller in my blueprint controller. It display a widget, wait for an action of the player, disappear and move the player to a certain location.
Work fine for the player 1, but not the rest :frowning:

I tried to do everything in the game state and it’s not working either, so I create a simple test (I add a navmesh for it to move)


Problem, it’s not moving at all.

Sorry for this long text but I wanted to give as much informations as possible, does someone already face this situation ?

Thanks in advance for anyone willing to help me or just post a message :grin:

Does someone could have a solution for this problem ? Thanks :grin:

Then, I tried to send this selected controller in my blueprint controller. It display a widget, wait for an action of the player, disappear and move the player to a certain location.
Work fine for the player 1, but not the rest :frowning:

I tried to do everything in the game state and it’s not working either, so I create a simple test (I add a navmesh for it to move)

Hello @Alejandroagyra , there’s maybe a problem with the display of your post but I only see a copy of a sentence I wrote, did it not make any sense ?

Just in case, I saw that the node “Simple move to location” need a Nav mesh bound place on the world in order for the character to move.
I’m plugging the player controller and a vector, it’s working fine for the player 1, but not for all the others players.

Even by changing the index by hand in the game state (it will not work in the controller blueprint), the others players won’t move.

The test with the widget TRUE or FALSE ensure me that I’m able to differenciate the controller from each player but unfortunately, not the movement :frowning:

Your MoveTo will fail because its being run on the client.

If you read the subtext it says (ReplicatedToAll IF Server)

That said movement should only be done on server anyway so change that RPC to RunOnServer.

If the Actor has movement replicated which characters do, it’ll work on that alone

Hello @Auran131 , sorry to reply just now :sweat_smile:

So Imodify slightly the node but it didn’t work, here in image what I’ve done

So first, I tried to only affect the custom node move to and try every replicates options available > not working :frowning:

So after that, I create another custom node set on “Run on server” and plug the “MoveTo” that I put on multicast to begin and then, test with all the other replicates options > same result (the server is moving, not the the other players).

I also try to check replicate the movement and replicate in the controller blueprint, but nothing either.

I’m pretty sure that the problem is not difficult, but I just don’t get why it will not replicate the movement to the other players :sob:

unfortunately i think its better to start over here, i understand you’re probably just testing but you’d never move a character on RepNotify.

Reason being is you cant set the location or speed, they’re hard coded.

You must have a server event that sets the active player, the server can then tell that player to move if thats what you want. although i assume you’d want the player to select a location?

In my main code, I’m getting an array of Player Controller from the Game Mode function OnPostLogin.

I’m calling the game mode in my game state and settings a local variable from this array.
Then, with a switch from an enumerator variable, I’m getting to the player turn.

There, I’m using my array “GS_PlayersController” and an integer variable to control the index. All the code after that is based on the choosen controller.
I put different conditions for gameplay reason and when the player launch a dice, I made a loop so that the player will move to each square board of the map, one by one.

This function is working just fine with one player but not with multiplayer, I’ll make a cleaner version of the code in a new project that I put in the conversation if it can help :grin:

I put back the previous the image that bug

And here the project :

So all movement should be done on the server, the actor can have movement replicated to clients.

all the client need to send is a MoveRquest, this could be a vector or in your case sounds like a dice roll. in that case though the dice roll would be server side too so basically all the client is send is a confirmation (i’ve clicked a widget or whatever)

you dont need to disable any input, when the client requests to move the sever can check, IsClientTurnActive.

Thanks again for taking the time to help me, I really appreciate :blush:
I will make some tests from what you said and I’ll come back to you when I’ve got something :grin:

It’s been a long time, but the solution was really simple, but not very obious I wouild say.
You have to go to your project settings > Engine > Navigation system and check on the settings “Allow Client side navigation”

This way, the move to location is working with client.

Hope it could help some peoples :smiley:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.