Open thegrb93 opened 7 years ago
Here's another simple test. The entity should hover without moving at all, but it slowly falls due to this.
local e = Entity(301):GetPhysicsObject()
hook.Add("Think","T",function()
e:ApplyForceCenter(Vector(0, 0, e:GetMass() * 600 * engine.TickInterval()))
end)
^ I know that the downward descent can't be prevented due to physics iterations in between Thinks, but the net velocity should remain stable at 0 I would think. I plotted the velocity of the prop at each think.
Okay, I was able to make sense of that plot.
The ramp indicates that ApplyForceCenter is putting slightly too much force on the prop. Seems to be trying to compensate for the spike. The spike indicates a frame where no force at all is applied to the prop.
The spike is exactly gravity*engine.TickInterval()
This is happens every 99 frames.
Physics simulation is not synchronized to the Think hook.
Yeah I know, but is there a way to make it more uniform? If so, then I think that should be the default setting.
I just found out this only happens in multiplayer. In singleplayer it's fine.
Use the Physics* hooks, this requires you to use scripted entities though.
Addons such as E2 and Starfall which use Think to simulate physics on prop_physics can't do that.
@G-Force007 This isn't related to CurTime imprecision. The jitter is an interval.
Do not use Think for this, use PhysicsSimulate instead and use its specified delta time.
Also keep in mind theres interpolation involved aswell, since theres no clientside physics object and I'm guessing no clientside logic to move the object you can only snap to the last server value.
The anomolies were measured in serverside.
For some reason, things like ApplyForceCenter are not consistent in the Think hook. I've made a plot of d/dt-CurTime vs SysTime and also a video showing this periodic jitter.
Pretty much all E2 creations are affected by this. If we could get it consistent then things would be much better.
The spikes here seem to be periodic every 0.5 sec.
The physics jitters seem to be periodic every 1sec. (Yes I'm certain it's not the dynamics of it oscillating. It jitters then stabilizes then jitters then stabilizes etc...) https://www.youtube.com/watch?v=W0OYG6K0jjs