Search Unity

GhostPredictionSystemGroup and Physics

Discussion in 'Entity Component System' started by dzamani, Dec 3, 2019.

  1. dzamani

    dzamani

    Joined:
    Feb 25, 2014
    Posts:
    122
    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:
    37
    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:
    246
    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:
    37
    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