# UMG custom hit box on a button or image

**URL:** <https://forums.unrealengine.com/t/umg-custom-hit-box-on-a-button-or-image/353302>\
**Category:** UI\
**Tags:** button, unreal-engine, hitbox, Widget, question, UMG\
**Created:** [April 7, 2016, 3:07pm UTC](https://forums.unrealengine.com/t/umg-custom-hit-box-on-a-button-or-image/353302 "2016-04-07T15:07:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_2c124cb81](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2c124cb81](https://forums.unrealengine.com/u/anonymous_user_2c124cb81)\
**Post date:** [April 7, 2016, 3:07pm UTC](https://forums.unrealengine.com/t/umg-custom-hit-box-on-a-button-or-image/353302/1 "2016-04-07T15:07:32Z")

</div>

Hello,

Is there any way to make a custom hit box on a button, or other Widget control?

I have an image of a button that has the following shape

![85789-customhitboxbtn.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/4/f/a4fce8d5c2975b6dcf490abe8f1394827c2a3a9f.png)

And I’d like the hitbox to be exactly the shape of the image, not a rectangle. Is this feasibile?

Thanks.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b730fea1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b730fea1](https://forums.unrealengine.com/u/anonymous_user_b730fea1)\
**Post date:** [September 27, 2016, 11:23pm UTC](https://forums.unrealengine.com/t/umg-custom-hit-box-on-a-button-or-image/353302/2 "2016-09-27T23:23:54Z")

</div>

Try using this: https:/// download link is in description to the video.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2c124cb81](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2c124cb81](https://forums.unrealengine.com/u/anonymous_user_2c124cb81)\
**Post date:** [September 30, 2016, 7:49pm UTC](https://forums.unrealengine.com/t/umg-custom-hit-box-on-a-button-or-image/353302/3 "2016-09-30T19:49:33Z")

</div>

Thank you very much! I didn’t think that anyone would answer this after all this time 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b730fea1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b730fea1](https://forums.unrealengine.com/u/anonymous_user_b730fea1)\
**Post date:** [October 1, 2016, 9:19am UTC](https://forums.unrealengine.com/t/umg-custom-hit-box-on-a-button-or-image/353302/4 "2016-10-01T09:19:19Z")

</div>

I’ve found a bug there. Haven’t solved it yet. For it’s been working correctly, try to keep button’s size and hit box image size equal. And set button’s size manually.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1cdfa42d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1cdfa42d](https://forums.unrealengine.com/u/anonymous_user_1cdfa42d)\
**Post date:** [December 29, 2016, 8:43pm UTC](https://forums.unrealengine.com/t/umg-custom-hit-box-on-a-button-or-image/353302/5 "2016-12-29T20:43:17Z")

</div>

I found a fix for that bug you mentioned. All you need to do is change the BufferPosition calculation to floor the LocalPosition.Y value. The decimal point has no meaning in texture coordinates and it’s giving you the wrong pixel. So it should look like this:

```
int BufferPosition = (floor(LocalPosition.Y) * ImageWidth) + LocalPosition.X;

```

With this fix you can have a button size that doesn’t match the texture size.

---

<div class="post-metadata">

**Author:** ![Skjdljr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skjdljr](https://forums.unrealengine.com/u/Skjdljr)\
**Post date:** [December 2, 2018, 1:59pm UTC](https://forums.unrealengine.com/t/umg-custom-hit-box-on-a-button-or-image/353302/6 "2018-12-02T13:59:14Z")

</div>

Any one else having issues getting this to work with 4.20. I am getting a bunch of linker errors

---

<div class="post-metadata">

**Author:** ![Skjdljr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skjdljr](https://forums.unrealengine.com/u/Skjdljr)\
**Post date:** [December 2, 2018, 2:10pm UTC](https://forums.unrealengine.com/t/umg-custom-hit-box-on-a-button-or-image/353302/7 "2018-12-02T14:10:24Z")

</div>

Anyone else having compiler erroa when trying to use in version 4.20 of ue4?
