Sign In Register

How can we help you today?

Start a new topic

Unreal Engine Real Time Third Person Tutorial


I'm in the process of shifting my Unity game to Unreal Engine, and also shifting from using PlayFab + Photon (PUN) to using GameSparks, since GameSparks seem to be a more powerful tool after reading about it and testing it. So far so good.

What I'm trying to make a third person real time multiplayer. Now the problem is that I can't seem to find proper documentation for the unreal part for the real time multiplayer. I tried to see the Tetris Example, but I don't think it has what I need, or maybe it does but I can't seem to know what it is.

Can someone explain to me or guide me through the following:

After connecting to Gamesparks and logging in as 2 different users, and after matchmaking is complete, I start a session and I switch both clients to the game level (the game level consists of the normal "ThirdPersonExampleMap" that comes as a default with unreal engine's new third person project). When both clients join this level the third person character can't be controlled by the user. What I want to know is should I create a third person character manually for each player when the scene is loaded? and how can I make that character load on the other clients so they can see him, and how can I sync their position.

Thanks in advance!



Hey Chris, sorry for the late reply. I agree that this post will be helping us better understand the gamesparks real time using unreal.

I was able to fix receiving the OpCode 100 from the cloud, turned out I forgot to add the "contains" function. Now the clients are receiving the OpCode 100 and the game is starting.

The new problem is that when the game starts, I'm sending an OpCode 0 so the clients know that I spawned a new player. But this packet doesn't seem to get to the clients. While the OpCode 1 is for sending the location of the client, I'm able to receive it on the other clients. Seems kind of weird I can't figure the problem out.

I've attached the sending part of my blueprint and reattached the new receiving part(added a print string for received OpCodes, and attached the Data variable to the Spawn Player and Set Network Player Location). Both strings "Spawn Sent" and "Location Sent" are being printed, but only the Location is being received.

It looks like the Id in the Tetris example is a different variable than what I referred to. The Tetris example has its own custom variable called Id which is simply an integer that represents a shape. Each shape (I, L, and T) has a different integer so that integer can be passed to the other clients via the Send node. When the clients receive the data, the Blueprints should then recreate the shape based on the corresponding integer.

The Id variable is generated from GS when the MatchmakingRequest is sent. That part you can see if you test it in the test harness. You can obtain the Id's like this (also attached): add a GSMatchmakingNode, break the resulting Match Details Response, from there add a ForEachLoop that takes in the Opponents array, which produces GSplayer structs which you can break to get the Id of the opponents.

You have the "receive" end set up properly. Now you just have to actually "send" the data from within your Blueprint (attached). Picture it like the game Battleship. You each have your own game board, and you're telling the other person where your next move is. You have to send the data to them, and they have to receive it. After it is received they have to interpret it in a way that results in a perfect replica of your character as you see it.

I'm looking into making use of the Id variable. I didn't realize the Tetris example utilized it. I'll look into that tonight.

Keep the questions coming. You're helping me understand this better by trying to explain it, and this should help other people that have similar questions since UE4+GS is relatively new still.

Send Data.PNG
(70.2 KB)

Figured out that the 100 OpCode is sent from the real time script.

Still can't figure out from where the "Id" variable came from.

Now I've attached a "Print String" to the custom event "OnDataDelegate" so I can see the incoming packets, but it seems I'm not getting any. The other 3 custom events (on player connected/disconnected, and the onready) are working so I don't think I have setup anything wrong here, so the OnDataDelegate should be working.

I've attached 2 pictures showing the delegates part. Did I set anything wrong? Or should they work normally?

Thank you Chris.

Well I'm stuck  right now. In the Tetris project there seem to be an "Id" variable that you can use to send the new created actor to other clients, but I can't seem to figure out from where that variable came from.

Also I can't seem to know when all players have connected so I start the game, in the Tetris demo it shows that Packet 100 will be sent when all players are connected, but I can't seem to know where is this packet sent.

Maybe I'm missing a key point to understanding how the workflow of updating clients with new locations/rotation/spawning/etc...

This took me a while to figure out, but this link should help.

The way it works is you use the Game Mode to send your own player information to GameSparks. Then GS sends that data to the other clients. When they receive that data, they have their own Game Modes produce replicas of the other clients on your screen based on the data relayed from GS, which could include character class, position, rotation, velocity, etc.

The part I'm still working on is how to keep track of each player's data. I'm not sure how to link the data received from GS with the character on the map.

2 people like this
Login to post a comment