Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Enter the 2020.2 Beta Sweepstakes for a chance to win an Oculus Quest 2.
    Dismiss Notice

GhostPredictionSystemGroup and Physics

Discussion in 'Data Oriented Technology Stack' started by dzamani, Dec 3, 2019.

  1. dzamani

    dzamani

    Joined:
    Feb 25, 2014
    Posts:
    116
    Hello everyone,

    I am not sure about something in the NetCube sample, we see in the MoveCubeSystem that we handle inputs and actually move the cube while the system is in the GhostPredictionSystemGroup.

    That seems to work when you update the Translation but what about PhysicsVelocity ?
    First, should we even handle inputs here or was it done to make the sample a bit more simple to use / understand ?

    In order to apply a force to a PhysicsVelocity, I need to update after the ExportPhysicsWorld system (at least from what I'm seeing right now but I may have missed a step).

    Another related question, let's say we want a mobile game and that the inputs are events based (meaning that I don't poll them each frame), should there not be a way to send the command once, apply it on the server and never use it again until the next input event ? I feel like there is a tick that say "this input has been applied so you can forget about it" but I'm not sure which one.

    Thanks!
     
  2. drhodor

    drhodor

    Joined:
    Aug 18, 2013
    Posts:
    39
    You may want to try updating the system before the prediction group. Not sure what this does to prediction just yet, but it definitely works better than what happens when you try to update physics in the prediction group!
     
  3. dispatch_starlost

    dispatch_starlost

    Joined:
    Nov 17, 2017
    Posts:
    31
    I'm currently trying to get some nice physics based movement happening as well. Applying changes to velocity in the GhostPredictionSystemGroup doesn't work, applying outside the prediction group (before or after) at least moves the ghost, however it stutters a fair bit.

    Would also like to know the correct way...
     
  4. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    153
    I solved this by adding a JobComponentSystem that does nothing (just returns inputDeps) and forcing it to update after GhostPredictionSystemGroup and before BuildPhysicsWorld.
     
  5. dispatch_starlost

    dispatch_starlost

    Joined:
    Nov 17, 2017
    Posts:
    31
    I understand this is to force GhostPredictionSystemGroup to run before BuildPhysicsWorld, but it doesn't actually work for me - the systems stay put and the custom JCS sits before both physics and ghostprediction, like it ignores the [UpdateAfter(typeof(GhostPredictionSystemGroup))] declaration.

    Does running the GhostPredictionSystemGroup before building the physics world fix the stuttering?

    Edit
    I have the GhostSimulationSystemGroup running before the BuildPhysicsWorld system now (had to specify simulation instead of prediction, as its the root group), but if anything the stutter is even worse
     
    Last edited: Dec 16, 2019
unityunity