#Get Ping in Ecs Netcode
1 messages · Page 1 of 1 (latest)
haha, try it before but my pc cannt open project =))
car demo is a bit more forgiving
anyway this is my code for it
/// <inheritdoc />
protected override void OnUpdateAlways()
{
this.timeToTriggerUpdatesPassed += SystemAPI.GetSingleton<UnityTime>().UnscaledDeltaTime;
if (!this.EntityManager.TryGetSingleton<NetworkSnapshotAck>(out var snapshotActComponent))
{
return;
}
this.pingData = snapshotActComponent;
}
/// <inheritdoc />
protected override void OnUpdateVisible()
{
if (this.timeToTriggerUpdatesPassed < DefaultUpdateRate)
{
return;
}
this.timeToTriggerUpdatesPassed = 0;
var deviationRTT = (int)this.pingData.DeviationRTT;
var estimatedRTT = (int)this.pingData.EstimatedRTT;
this.pingLabel.text = estimatedRTT < 1000
? $"{estimatedRTT}±{deviationRTT}ms"
: $"~{estimatedRTT + (deviationRTT / 2):0}ms";
}```
basically you're just looking for NetworkSnapshotAck
hehe thank u so much
it seems ecs does not have UnscaledDeltaTime? how do u work around this?
You can use unityengine.time.unscaleddeltatime
All the time statics are burst compatible
Why i got rid of my unity time singleton