09-20-2017 05:20 AM
09-22-2017 11:38 AM
01-11-2018 03:37 AM
pieterdub said:
Hi OrionPS,
I have been working on a multiplayer Avatar sample in UE. In my sample, I am spawning the avatar pawns on the server with the following replication settings:bReplicates = true;bAlwaysRelevant = true;bReplicateMovement = true;
Client doesn't see Avatars at all:
Where are you spawning the Avatar? It it part of the scene? Or are you spawning it in BP?
Does the client see the locally controlled Avatar?
I believe you need to spawn the Avatars on the server so replication copies them to all clients.
In my GameMode (only runs on server), I use the OnPostLogin event to spawn each player's avatar and possess that pawn with the player controller that is a parameter of the OnPostLogin event:
here is the spawn that is down the line from the OnPostLogin:
So once the avatar's have been spawned and possessed with player controllers on the server, they are automatically replicated to all clients.
Movement:
When you say movement of the avatars is copied from the Server avatar, do you mean the movement of the hands/head etc or are you moving the avatar around with the sticks (moving the position of the avatar)? I assume you mean the hand/head movement but let me know if not.
In my sample, I am recording avatar movement packets for the local avatar, and sending them to the server who then replicates those packets out to all clients, and then the clients play them back.
Did you make any other modifications to the LocalAvatar code or are you using it as it was provided in the sample? I think the code in the sample is recording the movement data packets from the local avatar into a set of queues and that is playing back movement to all avatars (see void FOvrAvatarManager::QueueAvatarPacket(ovrAvatarPacket* packet) ). Right now, that function is writing the packet into all the queues in AvatarPacketQueues and isn't keeping track of which avatar the packet belongs to. So the server writes data into this queue, and then it is replicated to all clients which isn't correct. It was setup this way because the sample is single player and allows the user to spawn multiple remote avatars that all mimic the movement of the local avatar.
What you would need to do, is set the Key of the AvatarPacketQueue and use that to keep the queues separate. You could used the player's UserID as the Key for each queue. I believe you would also need to make an RPC call from each client to send the packet data to the server and then the server writes that into the correct queue in the AvatarManager.
I don't currently use the AvatarManager in my sample. I send the movement packets from the clients to the server, and each Avatar Pawn maintains a queue. Server puts the correct packets into each avatar's queue using a PacketKey, and then replication copies that to each client machine. Then in the tick function for any nonlocal avatars, I playback movement from its queue.
Let me know if this helps at all. Hopefully I will have the sample ready to distribute within a couple weeks.
01-16-2018 11:16 AM
06-30-2018 03:53 AM
08-15-2018 12:44 PM
08-16-2018 07:47 AM
08-22-2018 07:20 AM