# Change static mesh to other object with UMG button

**URL:** <https://forums.unrealengine.com/t/change-static-mesh-to-other-object-with-umg-button/438486>\
**Category:** Asset Creation\
**Tags:** object-reference, reference-blueprint, unreal-engine, UE4, question\
**Created:** [November 28, 2018, 4:00pm UTC](https://forums.unrealengine.com/t/change-static-mesh-to-other-object-with-umg-button/438486 "2018-11-28T16:00:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_d4d7c129](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d4d7c129](https://forums.unrealengine.com/u/anonymous_user_d4d7c129)\
**Post date:** [November 28, 2018, 4:00pm UTC](https://forums.unrealengine.com/t/change-static-mesh-to-other-object-with-umg-button/438486/1 "2018-11-28T16:00:44Z")

</div>

Hello I am still new in using the Unreal Engine. I start my project with the shooter starter content. After follow a tutorial, I am able to change the static mesh object to another by shooting. This is the blueprint how I set.

 ![260781-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/3/a/13afe9ce24a10c058f4fda44889e074391a610fb.png)

 ![260782-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/0/a/d0a37ae4ee49631b07aec23ee99c22e8784a5d99.png)

I want to change the current static mesh object to another by using the UMG button and this is my blueprint.

 ![260783-3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/7/b/27bd8f9dd663c536bb509bba17079e0deebcaeee.png)

But the button is not working. I know the “cast to destructive wall” need an object reference. In the event hit, the “other” pin will detect whether the object hit is same as the object references cast to. In the UMG button, What should I do to detect and get all the object match to the “cast to destructive wall”? How to change the static mesh to another by only click a button? Really appreciate if get any help or advice!

 ![260785-4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/d/6/9d6ae54242cdfeb964cf27b4fd469e804be27df3.jpeg)

---

<div class="post-metadata">

**Author:** ![Detilium](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/detilium/32/985007_2.png) [@Detilium](https://forums.unrealengine.com/u/Detilium)\
**Post date:** [November 28, 2018, 4:20pm UTC](https://forums.unrealengine.com/t/change-static-mesh-to-other-object-with-umg-button/438486/2 "2018-11-28T16:20:25Z")

</div>

In the first two images, you know that your projectile is actually hitting something, and therefore the `Event Hit` is triggered.

In this case, where you want to change a static mesh of some actor, the widget doesn’t know what actor to change the static mesh on, unless you tell it. You can create a new variable on the widget, and make it of type `DestructiveWall` (_you actually don’t need to cast then, as the variable knows what type it is_), then on the button click, you’d change the static mesh of your referenced actor. Here’s a simple blueprint to show what I mean:

 ![260769-tmp1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/1/e/21ef8af512749601f1d61a579c071f9c2f6f14c5.png)

I’ve marked the interesting things with orange. You’re welcome to ask any questions regarding this solution, and I’ll do my best to answer them 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d4d7c129](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d4d7c129](https://forums.unrealengine.com/u/anonymous_user_d4d7c129)\
**Post date:** [November 28, 2018, 5:22pm UTC](https://forums.unrealengine.com/t/change-static-mesh-to-other-object-with-umg-button/438486/3 "2018-11-28T17:22:39Z")

</div>

Hi, thank you for your reply. I followed exactly to the tips you give but it doesn’t work ☹ Is there any mistake on the actor? I am really sure the button can function (tried with set the visibility of button).

 ![260803-5.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/a/e/5aee28e5608ed14dd69e86d27a989e1c1758f599.jpeg)

---

<div class="post-metadata">

**Author:** ![Detilium](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/detilium/32/985007_2.png) [@Detilium](https://forums.unrealengine.com/u/Detilium)\
**Post date:** [November 28, 2018, 6:45pm UTC](https://forums.unrealengine.com/t/change-static-mesh-to-other-object-with-umg-button/438486/4 "2018-11-28T18:45:10Z")

</div>

Do you set the reference variable? Please take an image of the blueprint where you add the widget to the viewport.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d4d7c129](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d4d7c129](https://forums.unrealengine.com/u/anonymous_user_d4d7c129)\
**Post date:** [November 29, 2018, 1:24am UTC](https://forums.unrealengine.com/t/change-static-mesh-to-other-object-with-umg-button/438486/5 "2018-11-29T01:24:22Z")

</div>

This is the blueprint of the widget where I put my button.

 ![7.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/4/5/945dd99121bff05bce5f5bb730950e0bc3e5be94.png)

I already set the reference variable as below.

![260845-8.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/c/5/ec5534d37066cd79c1ca38f8a13966e1b72889f2.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d4d7c129](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d4d7c129](https://forums.unrealengine.com/u/anonymous_user_d4d7c129)\
**Post date:** [November 29, 2018, 7:31am UTC](https://forums.unrealengine.com/t/change-static-mesh-to-other-object-with-umg-button/438486/6 "2018-11-29T07:31:57Z")

</div>

I tried to figure out the problem of the blueprint with color image. This is the widget and the blueprint.

 ![260880-11.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/9/2/5922ce1d84da49f2bd2f73b0d0f3222fe40db984.png)

 ![260881-12.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/5/3/053971298c7cfd3891c72a5778765039a92e0be9.jpeg)

If the set static mesh return a false boolean, the image color at top of the gameplay will change to green. I also set the static mesh to movable. Why the set static mesh always return false?

 ![260882-13.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/1/9/3196f416ebb11eb266c809a5fcef29b46f4eb4fc.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d4d7c129](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d4d7c129](https://forums.unrealengine.com/u/anonymous_user_d4d7c129)\
**Post date:** [November 29, 2018, 7:33am UTC](https://forums.unrealengine.com/t/change-static-mesh-to-other-object-with-umg-button/438486/7 "2018-11-29T07:33:11Z")

</div>

I tried to figure out the problem of the blueprint with color image. This is the widget and the blueprint.

 ![260880-11.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/9/2/5922ce1d84da49f2bd2f73b0d0f3222fe40db984.png)

 ![260881-12.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/5/3/053971298c7cfd3891c72a5778765039a92e0be9.jpeg)

If the set static mesh return a false boolean, the image color at top of the gameplay will change to green. I also set the static mesh to movable. Why the set static mesh always return false and the object did not change to new mesh?

 ![260882-13.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/1/9/3196f416ebb11eb266c809a5fcef29b46f4eb4fc.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d4d7c129](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d4d7c129](https://forums.unrealengine.com/u/anonymous_user_d4d7c129)\
**Post date:** [November 29, 2018, 4:21pm UTC](https://forums.unrealengine.com/t/change-static-mesh-to-other-object-with-umg-button/438486/8 "2018-11-29T16:21:05Z")

</div>

I figured out why my button doesn’t work. Because the object reference did not specify which object is want to change (it is possible to have many same objects). After the object is defined as an array index ‘0’, the static mesh can be set!

 ![260920-14.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/c/5/9c5a6e9d7afa79ece90e55138848640025872eff.png)

---

<div class="post-metadata">

**Author:** ![Detilium](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/detilium/32/985007_2.png) [@Detilium](https://forums.unrealengine.com/u/Detilium)\
**Post date:** [November 29, 2018, 7:07pm UTC](https://forums.unrealengine.com/t/change-static-mesh-to-other-object-with-umg-button/438486/9 "2018-11-29T19:07:32Z")

</div>

If you expose this variable on spawn (3rd checkbox in the variable details), you can set the variable whenever you spawn the widget
