Networked Player Controller Example

0

NOTE: Updated for Lumberyard 1.9.0.1!

This level shows a simple example of one way to create a networked player controller.

REMOVEDUPLOAD

To run:

  1. Extract the zip to your project's Levels folder.
  2. Make sure your project has the InputManagementFramework and Multiplayer Gems enabled, if not, enable them, lmbr_waf configure and build.
  3. Run your game launcher and load the map using the console command: map test_network_player_controller
  4. Next, start hosting using the console command: mphost
  5. ALT+TAB back to windows explorer and run a second launcher which we will make the client. After the second client launches in the console run: sv_port 0; mpjoin The client should connect to your local server and you should be able to move the player capsule around. The reason why we specify sv_port 0 is so the second client uses an ephemeral port so we don't try to bind to the same port that the server is already bound to. If you are connecting to another computer you wouldn't specify sv_port, but would instead issue the following command to connect to the host:

mpjoin <ip address of the host>

NOTE: This sample was built for LY 1.9, but should work in future versions as well.

5084-test-network-player-controller-ly19.zip|attachment (31.7 KB)test-network-player-controller-ly19.zip

Of course this is all simple stuff, no user interface, prediction, smoothing etc.

How this works:

The level has an entity called PlayerController that has a camera and input components and spawns a Pawn. After the Pawn is created the PlayerController sends input to the Pawn to move it around. Because the Pawn has a NetBinding component and the TransformComponent has NetBinding enabled, the Pawn's transform will be sent from the person that spawned it to all the other clients. This is client-authoritative which means it's not good for preventing cheating, but it's fine for prototyping.

If you want to implement network smoothing so the other hosts don't teleport around, disable the TransformComponent's netbinding and modify the Pawn script to send the transform from the controller to other clients using Lua NetRPCs and apply your position/rotation smoothing on those clients. Alternately, create a c++ component that does the same thing and add it to your Pawn.

asked 7 years ago186 views
8 Answers
0

Great to see samples like this. I will try it soon.

answered 7 years ago
0

Thanks for the feedback @REDACTEDUSER

answered 7 years ago
0

hey :-)

i would really appreciate if you could update this to LY 1.9.

I have tried it on my own, but without a proper API reference and editor it is to hard for me, because i do not know all the function names. (e.g. what do i have to call to get the parent via the transformbus? Where do i find the api-ref for the Transformbus? I checked the User+Dev Manual but did not find anything)

I just hope sth like intellisense is coming soon to the LUA editor :-) Then all this stuff would be so easy

Thanks in advance!

SH

answered 7 years ago
0

Hi @REDACTEDUSER

answered 7 years ago
0

Thanks!!

Sadly it does not work with 1.10 out of the box, i'm getting always this error:

I assume it has to do somehow with the gemsystem because for me all additionally enabled gems are not shown in the visual studio solution.

Anyway thanks for the update, i will use 1.9 then :)

answered 7 years ago
0

Hey i have another question.

How can i achieve to have collision between the spawned pawns? Just adding a collision component doesnt work :(

answered 7 years ago
0

Hi @REDACTEDUSER

answered 7 years ago
0

yea that was the problem, lmbr_waf configure does not create a new vs solution. But whats about my second question? :P How can i achieve collision between those two pawns? And i tried using the chicken as a pawn, it works but the animations did not get synchronized, is there not a prebuild support for synchronizing the animation state? What do i have to do? I really wish we would have an easy understandable multiplayer project e.g. the starter-game as a multiplayer-project would be awesome i guess.

answered 7 years ago

This post is closed: Adding new answers, comments, and votes is disabled.