Adding collision to a custom mesh component

Hello.

I have created a mesh using a custom mesh component.

How do I add collisions to it? I looked within it’s default tab and nothing comes up about collisions.

Is it even possible?

Hi ShrewGlue,

Adding collision to a custom mesh is not too difficult. You can do this via the your modeling program and setting up custom collision there or you can use the collision primitives in the mesh editor to add basic collision to your mesh.

Here is a video tutorial from one of our Moderators that shows you how to setup custom collision:

Here is a link to the official documentation for collision in UE4: FBX Static Mesh Pipeline in Unreal Engine | Unreal Engine 5.1 Documentation

Thank you!

Tim

Thanks for the reply but neither of these seems to fix my problem: My mesh has different sizes/ lengths/ rotations every time it’s spawned in the world. so it won’t have a single static collision.

My mesh is specifically a triangle, created with a “Set custom mesh triangles” node, which has an array with it’s vertices changing each time, thus making my triangle have different shapes and sizes each time it is created.

Is creating a collision for this customMeshComponent still possible?

Honestly, I’m not sure how to go about setting collision for this off hand since I haven’t really used any procedural generation. I don’t mind looking into it though if this suggestion doesn’t work.

After your Set CustomMeshTriangles node use a Set Collision Enabled node and change the collision type to “Collision Enabled.” I’m not sure if that will work though as it may require a target to enable the collision.

If you don’t mind could you post a simple version of your BP that spawns a mesh and I can see if this is something that can be enabled.

Thank you!

Tim

Thank you for your help so far! - Set actor enable collision does not work unfortunately.

Here is my simple Blueprint script:

I’m still having trouble even setting this up. I’ll be the first to admit I’m not a wizard with blueprints in some areas. Using arrays is definitely one of them.

Would you be able to provide a simple blank project with this setup so I can take a look with the mesh that is generated. I played around for about 45 minutes not really getting anywhere. :confused:

Thanks!

Tim

Here is a simplified uasset file. - I removed all the extra stuff that I have (basically tells it where to spawn) Just drag it onto the scene. An added material is there too. (Both of the .zip files are the same. Just different names) link text

Thanks! I can’t believe that’s all you did to set it up. I feel like a goober now. :slight_smile:

I’ve not narrowed down anything yet. Although, I am able to see the triangle in my scene when I go to PIE it is not there. I’ve checked all rendering settings to make sure it’s visible and tried toggling visibility. Is this the same case for you as well? Is it visible when you PIE?

Thanks!

Tim

Depending on the material you have the triangle is only visible from one side. If you add the attached material to the mesh component you should be able to see it in the view project in editor. The material has the “two sided” checkmark button checked in its settings. Once you have the material applied you should be able to view it from two sides. The triangle also spawns at certain coordinates. So it shouldnt appear in the same place where you dragged it, but rather around the 0,0,0 coordinate (thats one of its vertices) in the scene. I too had SO much trouble getting it to work and be visible within the scene.

Yeah I did set the material and placed checked it as two-sided; That was the first thing I did.

I did not, however, check that it was spawning at the the coordinates though. It could be that it’s at the BP origin in the viewport and play it spawns elsewhere. I’ll have to take a look at that portion.

Just to give you an update here.

A couple of the devs are going back and forth discussing this at the moment.

Nothing is set yet, but any works that needs to be done to bring that class up to date wouldn’t be started until after GDC in March.

I’ll update here when there is more information.

Tim

You can now try to use procedural mesh component.
that will create the collision automatically by passing a true Boolean to “create mesh section” blueprint or function

Stumbled upon this and just discovered the custom mesh component. Any update on this?

Any update ? This is really a needed feature. No collision for custom mesh component made with custom triangles is really bad.