# How to get the viewport center

**URL:** <https://forums.unrealengine.com/t/how-to-get-the-viewport-center/294742>\
**Category:** UI\
**Tags:** size, hud, viewport, unreal-engine, question\
**Created:** [September 27, 2014, 10:02pm UTC](https://forums.unrealengine.com/t/how-to-get-the-viewport-center/294742 "2014-09-27T22:02:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahopps01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ahopps01](https://forums.unrealengine.com/u/ahopps01)\
**Post date:** [September 27, 2014, 10:02pm UTC](https://forums.unrealengine.com/t/how-to-get-the-viewport-center/294742/1 "2014-09-27T22:02:05Z")

</div>

Hello, I’ve seen some other questions about this but I am having a problem, I guess with my HUD. When I use Get Viewport Size for my Player Controller, it returns 0. I have a HUD set up but I’m not sure what it’s missing so that Get Viewport Size doesn’t return 0. Any help is much appreciated. Let me know if you need any further information!

---

<div class="post-metadata">

**Author:** ![Erasio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Erasio](https://forums.unrealengine.com/u/Erasio)\
**Post date:** [September 27, 2014, 10:48pm UTC](https://forums.unrealengine.com/t/how-to-get-the-viewport-center/294742/2 "2014-09-27T22:48:11Z")

</div>

You should get the size of the render window in pixels with your “Event Receive Draw HUD”.

It two outputs “Size X” and “Size Y”. They represent the size of the window in which the game is played.  
The center would be a Vector2D from “Size X / 2” and “Size Y / 2”.

---

<div class="post-metadata">

**Author:** ![ugmoe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ugmoe](https://forums.unrealengine.com/u/ugmoe)\
**Post date:** [May 1, 2021, 4:04am UTC](https://forums.unrealengine.com/t/how-to-get-the-viewport-center/294742/3 "2021-05-01T04:04:03Z")

</div>

If anybody got here from google and looking for a more up to date answer. Here is how you get the middle of the viewport with the new widget system:

 ![337609-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/3/d/c3d2a020813f99aba622f5f3a787c3e688eb95af.png)

---

<div class="post-metadata">

**Author:** ![Barbat0s1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Barbat0s1](https://forums.unrealengine.com/u/Barbat0s1)\
**Post date:** [May 19, 2023, 3:10am UTC](https://forums.unrealengine.com/t/how-to-get-the-viewport-center/294742/4 "2023-05-19T03:10:13Z")

</div>

Thx you save me

---

<div class="post-metadata">

**Author:** ![crossmr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@crossmr](https://forums.unrealengine.com/u/crossmr)\
**Post date:** [December 2, 2023, 4:16pm UTC](https://forums.unrealengine.com/t/how-to-get-the-viewport-center/294742/5 "2023-12-02T16:16:49Z")

</div>

Should clarify, this needs to be run on a widget that occupies the whole screen. This returns the center of the current widget.
