Networked Player Controller Example

NOTE: Updated for Lumberyard!

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

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:
  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:


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

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.

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

Thanks for the feedback @SilvanHau. We have quite a few updates coming to the Lua editor in the next couple of updates. I’ll make sure the team sees this feedback.

hey :slight_smile:

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 :slight_smile: Then all this stuff would be so easy

Thanks in advance!


Hi @SilvanHau, I’ve updated the sample, let me know if you have any questions - enjoy!


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 :slight_smile:

Hey i have another question.

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

Hi @SilvanHau, do you have the InputManagementFramework gem enabled? Maybe also enable the StartingPointInput gem too. If the gems aren’t showing up in your visual studio solution make sure you run lmbr_waf configure, and if they still aren’t showing up after that try force generating the visual solution using lmbr_waf msvc. There may be a bug with new projects in 1.10 where lmbr_waf configure doesn’t properly update your project due to the way new projects are created.

yea that was the problem, lmbr_waf configure does not create a new vs solution. But whats about my second question? :stuck_out_tongue: 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.