- Newest
- Most votes
- Most comments
Hi @REDACTEDUSER
You are on the right path! Adding a netbinding component is needed to "bind" an entity to the network so its data gets replicated. I posted a simple example of a networked player controller a little while ago: https://forums.awsgametech.com/t/networked-player-controller-example/2277/1
The sample has lua code that needs to be updated to work with 1.9, but if this is something that you think would be useful for your game I'd be happy to update it for you.
It is client-authoritative and each player that joins the server has their own character they control.
Regarding your questions
0.) Do you have to write your own C++ Server?
Lumberyard comes with a dedicated server out of the box, so you don't need to write any C++ code if you just want to use Lua. That said, most multiplayer games do add/modify the C++ code for their dedicated server to optimize performance and to facilitate better security. If you are making a simple game where those are not issues (for example a prototype) then you don't need to write any C++ server code.
1.) I couldn't figure it out how the game-server terminates game-sessions. When i tried this, you can create a session using the lobby but is there really no way to delete a session?
There are C++ commands to terminate GameLift game sessions from the server, however in the multiplayer sample the dedicated server waits to receive a terminate message from GameLift before shutting down. So this means the client initiates the session creation, but GameLift handles the session termination in the sample. If you want your server to terminate the GameLift session you could call AWS::GameLift::Server::TerminateGameSession() (http://docs.aws.amazon.com/gamelift/latest/developerguide/integration-server-sdk-cpp-ref-actions.html#integration-server-sdk-cpp-ref-terminategamesession)
2.) Created player-sessions get not disconnected aswell, that means with every new Connection from a Client to a game-session the amount of active player-sessions increased by one, but never decreased even when i terminated the client program.
This sounds like the players are disconnecting incorrectly and the server has disconnect detection turned off? When a player disconnects the server is supposed to call Aws::GameLift::Server::RemovePlayerSession (line 247 of GameLiftServerSession.cpp in OnReplicaDeactivate).
thanks :) i just need an easy way to instantiate a player for each connection to the gameserver
Thanks, i'll try your character controller in the weekend.
One last question regarding "0.) Do you have to write your own C++ Server?"
Yea i know that lumberyard comes with a dedicated server out of the box and do the replication stuff etc. automatically, but say i am doing a prototype for my game, how does the server knows how to behave for this specific game? E.g. for a racing game the server has to manage obviously some sort of Leaderboard or handle when the race has been finished and transition all players to a new race. Is the only way to do this using C++?
Edit:
What i try to achieve is to spawn the controllable chicken from the samples project for each player, so each player can walk around. I tried this by just adding the netbinding-component to it, but the result of this is weird. The Chicken itself gets replicated from each client, but a cient is not able to move it (the server itself is able to move around but this chicken gets not replicated). Can you explain me why?
Hi @REDACTEDUSER
If you want players to be able to control a character, either the client needs to spawn the character in which case the client owns it - or the server needs to spawn the character and only allow one client to control it. The first method is client-authoritative and is what the sample I posted does. Take a look at that setup to make sure you aren't spawning a slice that has a controller on it. You just want to spawn a single player controller for each client and spawn the pawn dynamically. It sounds like maybe you are dynamically spawning multiple player controllers.
For the server-side logic you can start out with an entity that has a Lua script that only runs on the server. I typically expose the gEnv->pNetwork->IsDedicated() and gEnv->pNetwork->IsClient() to Lua so I can prototype quickly. However, this is not secure for a real game. The best way to secure your server logic is to only include that code on the dedicated server. You can implement that logic in Lua and load it (the compiled lua) on the server if you want, or just write it in C++.
This post is closed: Adding new answers, comments, and votes is disabled.
Relevant content
- asked a year ago
- asked 10 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago