How do I get ping values to use in a widget?

I want to make a ping (ms) counter, I’m trying to figure out how to use the node called “Get Ping in Ms” but I’m not sure how to use it. Therefore, how can I get ping values from my internet to display in a widget?

Hi Thecooldude1481

“Get Ping in MS” requires the data of the current session you are connecting to.
Information can be found here: Online Session Nodes | Unreal Engine Documentation

You could also implement a PlayerState class that has a variable “ping” you can access which returns the ping of the owning controller.

Thanks

Alex

Highly appreciate an answer! I believe I’ve got it working, however, I’m not sure if it’s proper. I’m getting ping from 9 and 10 (for 2 viewports in PIE) and then like around 5ms (for 1 viewport in PIE). I provided screenshots to show you what I made according to my understanding of your answer. I’m aware the connection is direct, however, I just want to verify if my nodes seem alright.

, Thanks

Hi Thecooldude1481

I am glad you found my answer helpful. Please mark it as the correct answer in case anyone else has a similar issue.

Your solution should work. However, why are you setting the ping on the pawn, to then just access the ping from the pawn when you could just access the Player State directly.

As a rule of thumb, avoid casting on Event Tick as casting in blueprints is very expensive.

Take a look at my answer to this question: https://answers.unrealengine.com/questions/995167/spawning-a-number-of-actor-from-a-variable-of-play.html

Further, in the replies, I post an example of how you can bind a variable from the Player State without needing tick and only using a single cast.

Good luck

Alex

1 Like

Oh I see how this works. Seems like I learned more things today! You answer is now marked as a solution and thanks again!

Glad you got it sorted. Good luck!

can you tell me how you got the Get ping in ms to work ?

Hi Hashem, so basically ideally in the Player State Blueprint, you’d want to use the “Get Ping in ms” node and make it set a variable for it. For the variable it is setting, you could create a widget and make a bind for a text item that gets actor of Player State, and gets the variable that we use to get values from the “Get Ping from ms” node.

that’s what worked for me

1 Like

That looks like it would be more logical as it already has replication.

Thanks for sharing!

Hi everyone,

@HashemShepard can you explain why the *4 multiplier ate the end? I’m trying to make a similar meter.

Thanks

i dont really remember where i got the 4 from but im pretty sure it gets the right number with it.
Edit: yeah, that’s because they compress ping into a byte by dividing it by 4