Jump to content
  • Advertisement
Sign in to follow this  

Abilities involving movement + state sync

Recommended Posts

Server Authoritative 

What I'm doing right now is syncing the players position periodically and using some interpolation while any ability the player uses gets sent and played as soon as possible. Everything seems to work ok in parallel if the abilities don't involve the player moving. If I were to use the same system for movement based skills I would have some trouble syncing VFX with the movement part of the skill because movement would only be managed by state sync. So my question is what would be the best approach to deal with this issue? Should the players position get "locked" at the start of the ability so the ability code could take care of the movement instead, should the state sync take care of both: positions and abilities or is there a better solution? I understand I can't just have state sync take care of the movement and ability code take care of the VFX because of abilities such as teleport for example.

Edited by Sparta

Share this post

Link to post
Share on other sites

I don't know what your network code looks like, but assuming you use something like a traditional "command" model, the best solution I know if is to have your "play ability X" command carry the state necessary to sync up the presentation of the relevant actor.

That's a mouthful, so here's a concrete example:

  • You have an ability "lunge" which starts with a rapid forward movement and then ends with a damage-dealing blast.
  • Player One is at position x0,y0,z0 at frame N
  • Player One sends an input packet from their PC to the server stating they wish to use the lunge
  • Server validates the ability as normal (e.g. is it off cooldown, whatever)
  • Assuming the input is valid, the server issues a command packet back to all the relevant players
  • The command contains the actual ability (lunge), combined with any position, velocity, acceleration, etc. necessary to describe the server's perspective of where Player One was at the time of frame N
  • Other players apply latency compensation as desired
  • Player Two's machine will now interpolate from "Player Two's idea of where One is at" -> "Server authoritative state of One" over suitable number of frames


Note that some parts of this may vary depending on your netcode, your simulation model, and your desired tradeoffs (e.g. is it ok to trade accurate positions for faster response times? etc.)

Share this post

Link to post
Share on other sites

First, make sure your simulation runs at a fixed step rate (whatever -- 30 Hz, 60 Hz, 120 Hz, 1000 Hz, ...)

You can run graphics asynchronously from physics -- check out the canonical game loop for one way of doing that. (On the server, there's no graphics, but time still needs to advance using a real clock.)

Then, timestamp both movement, and action commands, using "this takes effect at physics step X."

Then, you should be able to make positions and actions sync up, because you can play actions and positions back at the same timestep. Now, whether that timestep is the "global" time step X, or the "local" time step X for the viewer, or some time step X+Q where the lag from sender to receiver is Q, depends on the specifics of your networking and simulation models.


Share this post

Link to post
Share on other sites

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
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Similar Content

    • By ethancodes
      I'm working on a system for my game that will allow the player to stack pick ups in a queue. As one pick up expires, the next automatically activates. I'm having an issue though where if I pick up the first one, it activates fine, but if i pick up a second directly after it, it overrides the first one, activates the second one, and then once it has run it's course, everything goes back to normal gameplay, no first pick up. I'm not sure why this is happening. Hopefully someone can spot what I'm doing wrong in my code.
      Here is the code for the pick up manager:
      // Update is called once per frame void Update () { if (pickUpQueue.Count != 0 && !pickUpActive) { pickUpActive = true; pickUpQueue[0].ActivatePickUp(); } DeactivatePickUp(); } void DeactivatePickUp () { if (pickUpQueue.Count != 0 && pickUpActive) { Destroy (pickUpQueue [0]); pickUpQueue.RemoveAt (0); pickUpActive = false; } } And here is the PickUp:
      public override void ActivatePickUp () { ball.GetComponent<Ball>().Speed = 2.0f; //increase ball speed... ball.GetComponent<Ball>().StartCoroutine(timer); //...set time that power up is active }  
      There is also a Base Pick Up:
      public void OnCollisionEnter2D (Collision2D collision) { Vector2 tweak = new Vector2 (Random.Range(0f, 0.2f),Random.Range(0f, 0.2f)); this.gameObject.GetComponent<Rigidbody2D>().velocity += tweak; //if the pickup makes contact with the paddle or ball.... if (collision.gameObject.tag == "Paddle" || collision.gameObject.tag == "Ball") { GameObject.FindObjectOfType<GameManager>().GetComponent<PickUpManager>().pickUpQueue.Add(this); Destroy(gameObject); //...and finally destroy power up object } } As a side note, I am trying to find a solution to this that will work for all of my pickups. Some pickups are ammo based, some are timed. 
    • By Hellados
      Hello guys, my name is Giorgi and i'm newbie game developer i'm learning Pixel art and after pixel art  i want learn C# and don't know how and where start i'm bad with programming language and know only HTML/CSS
    • By D34DPOOL
      Edit Your Profile D34DPOOL 0 Threads 0 Updates 0 Messages Network Mod DB GameFront Sign Out Add jobEdit jobDeleteC# Programmer for a Unity FPS at Anywhere   Programmers located Anywhere.
      Posted by D34DPOOL on May 20th, 2018
      Hello, my name is Mason, and I've been working on a Quake style arena shooter about destroying boxes on and off for about a year now. I have a proof of concept with all of the basic features, but as an artist with little programming skill I've reached the end of my abilities as a programmer haha. I need someone to help fix bugs, optomize code, and to implent new features into the game. As a programmer you will have creative freedom to suggest new features and modes to add into the game if you choose to, I'm usually very open to suggestions :).
      What is required:
      Skill using C#
      Experience with Unity
      Experience using UNET (since it is a multiplayer game), or the effort and ability to learn it
      Since the game currently has no funding, we can split whatever revenue the game makes in the future. However if you would perfer I can create 2D and/or 3D assets for whatever you need in return for your time and work.
      It's a very open and chill enviornment, where you'll have relative creative freedom. I hope you are interested in joining the team, and have a good day!
      To apply email me at mangemason@yahoo.com
    • By Andrew Parkes
      I am a talented 2D/3D artist with 3 years animation working experience and a Degree in Illustration and Animation. I have won a world-wide art competition hosted by SFX magazine and am looking to develop a survival game. I have some knowledge of C sharp and have notes for a survival based game with flexible storyline and PVP. Looking for developers to team up with. I can create models, animations and artwork and I have beginner knowledge of C sharp with Unity. The idea is Inventory menu based gameplay and is inspired by games like DAYZ.
      Here is some early sci-fi concept art to give you an idea of the work level. Hope to work with like minded people and create something special. email me andrewparkesanim@gmail.com.
      Developers who share the same passion please contact me, or if you have a similar project and want me to join your team email me. 
      Many thanks, Andrew.

    • By mike44
      The reference assemblies for framework ".NETFramework,Version=v3.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

      what to do with the above error in ms code/Unity3d Project on Ubuntu 18.04? I've installed it like:
      Many thanks
    • By JoAndRoPo
      While going through a Game Design Document Template, I came across this heading - Core Game Loop & Core Mechanics Loop. 
      What's the difference? Can you provide some examples of an existing game?  Suppose if I am including these topics in a Game Design Document, how should I explain it so that my team can understand? 
    • By Dave Haylett
      I have pulled in five NuGet packages for my Visual Studio 2017 project, however when I build the project, VS spits out 10 .DLL and .XML files in the root of the binary folder, to do with the packages. Can't I shove them into a \packages folder so the user doesn't see these ugly resources next to the .exe file?
      I've Googled moving the packages but the only responses seem to be around moving the installation folder of the NuGet packages on the local machine, as opposed to where VS builds them to.
    • By MoreLion
      hey all! We are looking for members for our Unity horror game! 
      Here’s the story:
      After a deadly virus plunges the world into chaos killing 85% of the human population there are now what they call “zones” these zones are watched very closely by the surviving government, people are checked every day for the virus, even if you touch the spit or any human waste or fluids of the victim who is infected, you will die. But one day, people in the west zone start to go missing, 1 woman goes outside the walls to uncover the mystery, is there more to the virus than meets the eye?, That is where your story starts.
      This game is not a long development game, I have loads other game ideas,
      I will also allow you to have a bit of creative freedom if you wish to add or share a idea!
      And no, it’s not a zombie game lol I feel like zombie games are too generic, in this game you will encounter terrifying beasts!
      There is some concept art one of our concept artists have made
      If interested email liondude12@gmail.com
    • By Victor Rodriguez
      Hi there! Is the first time that I'm posting here so I'm sorry if I'm doing it wrong ha. 
      So here it comes, my doubt is, I'm doing a game with different levels, each of these levels in one different scene. Each scene contains to cameras that you can change pressing a button. Everything works fine. 
      The only problem is that I would like it to look a bit more professional, and I would like that if you finish the level with camera2, the next level start the same way. I've been thinking about using dontdestroyonloadon both cameras, but obviously this cameras need to be attached to the player to make the movement work, what do you recommend? Sorry If I've explained it in a messy way, and feel free to dm me for anything. Thanks in advance! 
    • By MoreLion
      The Standing

      After a deadly virus plunges the world into chaos killing 85% of the human population there are now what they call “zones” these zones are watched very closely by the surviving government, people are checked every day for the virus, even if you touch the spit or any human waste or fluids of the victim who is infected, you will die. But one day, people in the west zone start to go missing, 1 woman goes outside the walls to uncover the mystery, is there more to the virus than meets the eye?, That is where your story starts.

      A Terrifying Adventure. A Ton Of Lore To Explore. First person Shooter view point. Kill, or be killed.  

      Team Name:
      Team Rebound

      Team Structure:
      Rio Dakota (Project Creator)
      Lead,Game Design,Writer
      Bastaird (Concept Artist)
      Kat (Main Character Actor)
      Voice Actor

      Previous Work:
      Project FreeFall - Unknown If Released

      Talent Required:
      Unity Programmer(3)
      Must know how to work with other Members. must know how to use unity engine Must know how to work with modellers etc Required:Must Know C#  
       3D Artist (3D Animators, Hardsurface modeller etc etc)(3)
      Ability to export Models Experience with Unity toolset a bonus. Expected to create additional props & hard surfaces for use in environments.
      3D Character Artist (1)
      Experience with Maya Or blender Or Cinema4D required. Experience with Unity toolset is a bonus. Required to create, rig and animate player, npcs & monsters. Contact:
  • Advertisement
  • Popular Now

  • Forum Statistics

    • Total Topics
    • Total Posts

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!