# How do I enable collision for custom mesh at runtime?

**URL:** <https://forums.unrealengine.com/t/how-do-i-enable-collision-for-custom-mesh-at-runtime/295184>\
**Category:** World Creation\
**Tags:** unreal-engine, procedural-mesh, Collision, CPP, Blueprint, question\
**Created:** [October 3, 2014, 1:24pm UTC](https://forums.unrealengine.com/t/how-do-i-enable-collision-for-custom-mesh-at-runtime/295184 "2014-10-03T13:24:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_a9c6d18c1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a9c6d18c1](https://forums.unrealengine.com/u/anonymous_user_a9c6d18c1)\
**Post date:** [October 3, 2014, 1:24pm UTC](https://forums.unrealengine.com/t/how-do-i-enable-collision-for-custom-mesh-at-runtime/295184/1 "2014-10-03T13:24:17Z")

</div>

I’ve successfully assigned an array of triangles to a custom mesh, and it’s displaying just fine. What would be the best way to enable collision for this mesh during runtime? I want the player to be able to walk upon the mesh.

I am using a 3d simplex noise function in C++ that I’ve exposed as a blueprint node to generate the terrain on the fly, seeding a random float to the Z value for randomization, using the rest of it as a 2d noise function (hope that makes sense). Long story short, I’m generating random terrain via custom mesh triangles, and I want to walk on it.

Here is my unsuccessful attempt to add collision:

 ![16961-terrianbp.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/e/3ce365d4ebbba35cd583b28cccdbf1ff22db7817.jpeg)

And here is the screenshot of the custom mesh triangles in case anybody was interested in seeing what I’ve got so far (they still don’t have collision though):

[](https://i.imgur.com/6qAeEnm.jpg)

I’m also trying to find out what other problems I might run into in terms of AI, navmesh, and level streaming using a noise function to generate a world. As far as I know, there aren’t a lot of examples of this type of world generation in UE4, and I’m interested in what kind of trouble I might run into later, but I’ll save those troubles for other questions, right now I really just want that collision!

If there is a better way to generate terrain like this, I’d love to hear it as well.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a9c6d18c1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a9c6d18c1](https://forums.unrealengine.com/u/anonymous_user_a9c6d18c1)\
**Post date:** [October 4, 2014, 12:43pm UTC](https://forums.unrealengine.com/t/how-do-i-enable-collision-for-custom-mesh-at-runtime/295184/2 "2014-10-04T12:43:19Z")

</div>

It would be really neat if there was a way to feed my noise height values to a landscape at runtime, and use that instead, but as far as I know, that is not supported for landscape.

---

<div class="post-metadata">

**Author:** ![Mattlauk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mattlauk](https://forums.unrealengine.com/u/Mattlauk)\
**Post date:** [October 13, 2014, 12:52am UTC](https://forums.unrealengine.com/t/how-do-i-enable-collision-for-custom-mesh-at-runtime/295184/3 "2014-10-13T00:52:10Z")

</div>

As far as I know, this is currently not available by default in the custom engine.

A developer says something may be available in 4.5(Which is currently in preview) here:

> **[Implement Runtime Collision Detection for Procedural Generated Meshes](https://forums.unrealengine.com/showthread.php?2695-Implement-Runtime-Collision-Detection-for-Procedural-Generated-Meshes&p=137073&viewfull=1#post137073)**
>
> Currently, collisions detection for procedural generated meshes require either pre-cooking, or an aggregate of simple shapes to approximate mesh shape. In all cases, to detect mesh collisions requires fiddling under the hood, linking extra PhysX...

I did a bit of testing with this and it worked but it was extremely slow: (I did not troubleshot why it was so slow and it may be a simple fix)

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a9c6d18c1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a9c6d18c1](https://forums.unrealengine.com/u/anonymous_user_a9c6d18c1)\
**Post date:** [October 13, 2014, 5:39am UTC](https://forums.unrealengine.com/t/how-do-i-enable-collision-for-custom-mesh-at-runtime/295184/4 "2014-10-13T05:39:31Z")

</div>

Yeah from what I read, it doesn’t support non-editor physics cooking at runtime, although i might mess around with some of the code snippets from the wiki example. Thanks for replying though! hopefully there will be a way to do it in 4.5

---

<div class="post-metadata">

**Author:** ![Mattlauk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mattlauk](https://forums.unrealengine.com/u/Mattlauk)\
**Post date:** [October 13, 2014, 5:42am UTC](https://forums.unrealengine.com/t/how-do-i-enable-collision-for-custom-mesh-at-runtime/295184/5 "2014-10-13T05:42:41Z")

</div>

I’m hoping for the same thing. I downloaded the preview but haven’t had much time to screw around with it.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a9c6d18c1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a9c6d18c1](https://forums.unrealengine.com/u/anonymous_user_a9c6d18c1)\
**Post date:** [October 13, 2014, 10:19pm UTC](https://forums.unrealengine.com/t/how-do-i-enable-collision-for-custom-mesh-at-runtime/295184/6 "2014-10-13T22:19:01Z")

</div>

It would be cool if they made a blueprint node for making physics collision primitives with vertices or something like that. I don’t know exactly how the system works for assets generated at runtime though. I’m sure i could extend and expose some things to make one though if I dig around in that example.

---

<div class="post-metadata">

**Author:** ![Mattlauk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mattlauk](https://forums.unrealengine.com/u/Mattlauk)\
**Post date:** [October 13, 2014, 10:26pm UTC](https://forums.unrealengine.com/t/how-do-i-enable-collision-for-custom-mesh-at-runtime/295184/7 "2014-10-13T22:26:32Z")

</div>

That’s what I did and was running into an extreme amount of hanging. It would be best to create the mesh and collision in a separate task and then place in the world when it is finished.
