Has anyone had success creating an object with collision using the [Copy Procedural Mesh from Static Mesh Component] action? In all my testing the mesh falls through the floor when I enable “create collision” on this node. If I manually add collision by using the “Add Collision Convex Mesh” action it works fine, but I’m limited to box meshes for collision because I can’t see a way of generating an array of vertices from the copied mesh for the collision mesh.
I’ve been experimenting with this stuff quite a bit lately as well and believe what you’re describing is actually design intent. check out this thread. complex collision will probably work for collision channel traces (re: projectile impacts, visibility traces, etc), however physics will only use simple collision. so you’ll need to use ‘add collision convex mesh’ to create the collision extents at runtime. i haven’t done this yet, but i’d like to dive into the source and check out the code for the ‘auto generate convex collision’ function in the static mesh editor. i imagine, this can probably just be reimplemented at runtime to update collision on procedural meshes that change. in the meantime, you can use ‘get component bounds’ which will give you an origin point and box extent to work with. from there, you can plug in that data into a ‘generate box mesh’, and take the verts from the box mesh and plug them into the ‘generate convex mesh’.
Thanks for your input. I believe you are right.
The solution I was looking for was actually right there all the time. You can simply call ‘Get Section From Static Mesh’ to get the verts for the collision mesh. I couldn’t see the forest for the trees!
I’ve had problems getting CopyProceduralMeshFromStaticMesh to reliably generate collision for the procedural meshes it outputs. Trivial static meshes like cubes will usually work, and the starter content chair and statue work, but sphere meshes and weird shapes like SM_Rock have failed for me. I ended up unchecking the Generate Collision boolean on CopyProceduralMeshFromStaticMesh and then manually calling AddCollisionConvexMesh using the static mesh’s vertices as input, as graysan indicated in Paradoc’s answer. I wanted to put up an example blueprint for clarity, as it took me a bit to digest what Paradoc was suggesting.
This has reliably generated a convex collision bound for the handful of meshes I’ve tried it on, including ones with concavity like the starter chair, but I’d do some testing if you mesh has weird or highly concave geometries. Additionally, it gives you access to the static mesh geometry if you want to procedurally modify it later. Just make sure if you want to regenerate collision to ClearCollisionConvexMeshes and then call AddCollisionConvexMesh again using your modified vertices. CreateMeshSection’s GenerateCollision routine seems to fail in the same cases as CopyProceduralMeshFromStaticMesh.
@Spork you’re a lifesaver !