• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
  • entries
    34
  • comments
    61
  • views
    70072

Paper Cowboys: Enter the authoritative server

Sign in to follow this  
Followers 0
Gamieon

1237 views

Now that the intro and main menu concepts are done, I'm moving on to changing the networking model closer to authoritative server.



The goal is to minimize the chance for major conflicting game states (such as an explosion only happening on some clients) and to make speed and money hacks a little harder to do. It has to be done while trying to keep the game responsive and realistic (when my bullet hits the bad guy, I expect them to take damage). I also want to have the game support running as a dedicated server, which the current version does not support.

(Note: I develop in Unity, so what I write from hereon will be biased toward Unity developers)

The journey began with reading https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking and using it as a checklist for my implementation. So far, I've achieved Entity Interpolation and Input Prediction; I haven't done anything for Lag Compensation yet though it did give me some ideas. I'm also following these basic guidelines (not set in stone as I'm still learning, by the way):

  • You can't just blindly attach network components to everything in the game and call it a day. Every object has unique needs; some of them may not even need network components.
  • The server will almost ways be the one to instantiate network objects. The only exception to this are player objects that only require a visual presence, such as the player's stick figure arm rotating to show their aim.
  • The game should always immediately respond to keyboard, mouse, and joystick inputs.
  • Don't stream player inputs. Just send reliable messages when players press or depress buttons.
  • Servers and clients will both use collision detection for player-enemy contacts; but only the server will decide whether the contact results in hitpoint loss or visible damage.
  • Instantiations and buffered RPC's always get invoked first when a player joins. Minimize buffered RPC's and try to send them in the beginning of the object's lifetime if you have to; and make sure they get called in a predictable order.
  • Never trust the client.


    After a bit of work, you can see the results here. This movie was cobbled from videos taken on two different computers; one hard-wired to my FIOS connection and the other tethered from my smartphone. The video editing is imperfect, but I did my best to try to demonstrate how things look between the client and the server in a game with higher-than-desired latency.


    [media]
    [/media]




    The swinging stick figure arm follows the mouse cursor position of the owning player. It is a standalone object with its own network view where OnSerializeNetworkView will read the owning player's current rotation, and just assign it to the arm. No interpolation, no other magic involved. It is the only object in the scene; and at present the entire game, that clients can instantiate.

    The bullets that fire from the pistol are not network objects. When the server player fires, an RPC is sent to all the clients which includes the weapon ID and arm rotation; and then a local (non-networked) projectile is instantiated in the server's scene. When a client gets the RPC, they update the server player's arm rotation and instantiate a projectile in their client scene. Both the server and client's projectiles follow the rules of physics; but only the server decides if anything loses hitpoints in the process. The bullets are always launched from a position relative to where the player is standing at the time.

    When a client fires, an RPC is sent to the server with the weapon ID and arm rotation. After that, a local projectile is instantiated in the client's scene. When the server gets the RPC, it verifies that the client has the weapon and enough ammo to fire it. When it does, it RPC's a message to every other client that this one fired, and then instantiates its own projectile.

    When a client moves back and forth, the only RPC's exchanged between the server and client are the new client's velocity caused by the client pressing or depressing a button. Input Prediction makes sure the client's movements are immediate while being reasonable with the server's expectations; if the client strays too far they will get "rubberbanded" backwards as you may have seen in other games. Other clients simply use Entity interpolation to simulate the movements of the client and server players based on the data that the server gives them in OnSerializeNetworkView.


    This is my initial solution, and my comfort level is currently "uncertain." I need to see it in action before I can pass judgement. I suspect I will see reports of players shooting things but not killing them. I feel like I can do more about the projectiles, though I haven't figured out what yet. I also wonder if streaming unreliable player inputs are faster than using reliable messages; and if so, is it worth the additional traffic? After all, players are constantly moving and changing direction anyway, so maybe it won't make for that much more traffic?



    The next step



    Up to now, I've been entirely focused on engineering. I really need to map out the game design. This is the part that should be a lot of fun; but I also want to be careful about it. At one extreme, I could have a simple side scroller ala Sunset Riders with little enemy and weapon variety. At another extreme, I could have a very diverse ecology of enemies, a big weapon and item selection, leveling, skill trees, and plug-ins. Both can be fun in their own way; and though I favor the simpler scroller, there's something to be said about replayability in the presence of a leveling system and unlockable items.

    I also want to have randomly generated content in each level. For example, level 1 is a simple left-to-right walking level, but I want there to be different buildings every time. Level 2 is probably going to be a jump-the-platforms level like the waterfall level in Contra, and I want the platforms to be randomly placed.

0
Sign in to follow this  
Followers 0


1 Comment


I thought you were doing this in Unity. There's a thing called Photon for it. 

 

This'll be useful for creating code you can later use in your future projects.

 

What does it mean to tether a computer FROM a smartphone?

0

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now