# I want a "static" mesh that can change to a different static mesh through code.

**URL:** <https://forums.unrealengine.com/t/i-want-a-static-mesh-that-can-change-to-a-different-static-mesh-through-code/126638>\
**Category:** UDK Programming and UnrealScript\
**Tags:** unreal-engine\
**Created:** [May 26, 2019, 6:28am UTC](https://forums.unrealengine.com/t/i-want-a-static-mesh-that-can-change-to-a-different-static-mesh-through-code/126638 "2019-05-26T06:28:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathaniel3W](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nathaniel3W](https://forums.unrealengine.com/u/Nathaniel3W)\
**Post date:** [May 26, 2019, 6:28am UTC](https://forums.unrealengine.com/t/i-want-a-static-mesh-that-can-change-to-a-different-static-mesh-through-code/126638/1 "2019-05-26T06:28:38Z")

</div>

What I would like to do is damage a wall, and when the wall is destroyed, replace it with another mesh. What’s the best way to go about doing that? It doesn’t have to actually take damage like destructible mesh. Thanks for your help!

---

<div class="post-metadata">

**Author:** ![ciox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ciox](https://forums.unrealengine.com/u/ciox)\
**Post date:** [May 26, 2019, 10:50am UTC](https://forums.unrealengine.com/t/i-want-a-static-mesh-that-can-change-to-a-different-static-mesh-through-code/126638/2 "2019-05-26T10:50:14Z")

</div>

I have this code which I remember working

```auto

Begin Object Class=StaticMeshComponent Name=defmainmesh
StaticMesh=StaticMesh'test.testmesh'
Scale=3.0;
CollideActors=false
BlockActors=false
End Object
Components.Add(defmainmesh)
mainmesh = defmainmesh;

function Config(StaticMesh meshname)
{
mainmesh.SetStaticMesh(meshname);
}

```

Another thing I do when dealing with more complex stuff, is to have 2 objects at the same location and use SetHidden to show/hide either one or the other, that’s when the objects have very complex behaviors that I can’t just change by running one line of code.

---

<div class="post-metadata">

**Author:** ![NIDAL\_NIJM\_GAMES](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nidal_nijm_games/32/1213063_2.png) [@NIDAL\_NIJM\_GAMES](https://forums.unrealengine.com/u/NIDAL_NIJM_GAMES)\
**Post date:** [May 26, 2019, 1:06pm UTC](https://forums.unrealengine.com/t/i-want-a-static-mesh-that-can-change-to-a-different-static-mesh-through-code/126638/3 "2019-05-26T13:06:03Z")

</div>

I have done fractured meshes on my game, and for me it works perfectly.

You don’t need in example that the player actually shoots, hits the wall, just place a RB\_RadialImpulseActor to the map and trigger it via kismet, and it will cause the hit and destroy the wall.

Also you can add a particle effect in the front of the wall and trigger it to simulate an explosion.

If you need that the player can pass through the destroyed wall after the “explosion”, you need to place a blocking volume behind the fractured mesh (because it does not block collision) and whenever the wall is destroyed by the RadialImpulseActor you destroy the blocking volume. I have done all this in kismet.

Good luck 😃

---

<div class="post-metadata">

**Author:** ![Nathaniel3W](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nathaniel3W](https://forums.unrealengine.com/u/Nathaniel3W)\
**Post date:** [May 26, 2019, 4:27pm UTC](https://forums.unrealengine.com/t/i-want-a-static-mesh-that-can-change-to-a-different-static-mesh-through-code/126638/4 "2019-05-26T16:27:28Z")

</div>

Thanks ciox and udkultimate. I’ll give both of those a try and see which works for me.

---

<div class="post-metadata">

**Author:** ![NIDAL\_NIJM\_GAMES](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nidal_nijm_games/32/1213063_2.png) [@NIDAL\_NIJM\_GAMES](https://forums.unrealengine.com/u/NIDAL_NIJM_GAMES)\
**Post date:** [May 26, 2019, 4:34pm UTC](https://forums.unrealengine.com/t/i-want-a-static-mesh-that-can-change-to-a-different-static-mesh-through-code/126638/5 "2019-05-26T16:34:15Z")

</div>

For using RadialImpulseActor just take a look on the UDK ExampleMap.udk, that one which is in a kind of hangar, where you get an elevator then place a bomb on wall to open the passage to a small room where you fight a boss (bot).

Is from that map I got the fracture mesh idea:

 ![examplemap.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/b/a/ba1e46832d149bbb8e35e8a5d8025cbe5d40155c.jpeg)
