#Get Ping in Ecs Netcode

1 messages · Page 1 of 1 (latest)

fallen slate
#

is there a way to get ping in ecs netcode ?

wraith hemlock
#

check out the car demo (and maybe megacitynetcode)

#

they display ping on screen

fallen slate
#

haha, try it before but my pc cannt open project =))

wraith hemlock
#

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
fallen slate
#

hehe thank u so much

fallen onyx
wraith hemlock
#

All the time statics are burst compatible

#

Why i got rid of my unity time singleton