Applying collision to multiple models?

How would I, lets say I have over 400 wall models, apply collision to them all at once?

Hi deathclonic,

If you select multiple objects at once, you can change the Collision under the Details panel and it will change the collision for them all.

I hope that helps.

Thanks, TJ

Yes thank you. This is a life saver.

Using Unreal editor 4.19, I’ve imported (via Datasmith) many separate meshes for a floor (had to break it up for lightmap resolution reasons)

Perhaps I’m just being dumb but the solution posted above doesn’t appear to work any more.
Could anyone post a screen grab of the setting in the details panel (in 4.19) that will stop me falling through the floor? :slight_smile:

Otherwise, I have to go into the static mesh editor for each floor mesh (about 30 of them) and generate a simple box collision!

Another thought… perhaps there is a way to get Datasmith to recognise meshes than need collision by naming the object in 3Ds Max (where I’m exporting from)?

Cheers,
Graham

Hey, I think this topic was about setting collision type, rather than collision objects.

There’s a way to import custom collision objects with the mesh itself, see FBX Static Mesh Pipeline | Unreal Engine Documentation

If that’s not gonna be good for you, another option would be to create automatic pipeline that will run through all the meshes and generate them. This could help you out GitHub - 20tab/UnrealEnginePython: Embed Python in Unreal Engine 4

Hope it helps

Thank you, ex3me.

I used to use the UCX_ prefix when importing via FBX and that worked perfectly.
Shame Datasmith doesn’t support a similar system.

The Python plugin looks promising though. Will try it out and see how it goes.

In case it helps anyone else looking to do the same, here’s a potentially useful reference:

I have the Python plugin working only to create kdop10x collisions or better:

import unreal_engine as ue
from unreal_engine.structs import KAggregateGeom

mesh = ue.get_selected_assets()[0]
mesh.BodySetup.AggGeom = KAggregateGeom()
mesh.static_mesh_generate_kdop10x()
#Source: https://github.com/20tab/UnrealEnginePython/blob/master/examples/kdop.py

I guess kdop10x is not bad performance wise, however, it would be nice to generate “box simplified collision” for simple objects.

From the link I gave above there are two examples:
1st example:

import unreal_engine as ue
from unreal_engine.classes import StaticMesh, StaticMeshComponent

actors = ue.editor_get_selected_actors()
staticMesh = actors[0].get_component_by_type(StaticMeshComponent)
aggregateGeom = staticMesh.StaticMesh.BodySetup.AggGeom
struct = aggregateGeom.get_struct()
print(aggregateGeom.as_dict())
#LogPython: {'SphereElems': [], 'BoxElems': [], 'SphylElems': [], 'ConvexElems': []}
print(aggregateGeom.set_field("ConvexElems"))
#LogPython:[]

Which gives error:

list index out of range Traceback
(most recent call last): File
“”, line 5, in
IndexError: list index out of range

I’ve tried with one or many meshes selected in content browser and have tried changing actors[0] to actors[1] or actors[2]. All give same error.

2nd example:

import unreal_engine as ue

asset = ue.get_selected_assets()[0]
geom = asset.BodySetup.AggGeom

print(geom.as_dict())

Which does nothing at all to the mesh and simply prints:

{‘SphereElems’: , ‘BoxElems’: ,
‘SphylElems’: , ‘ConvexElems’: }

I only partially follow any of this code as I have no Python / C / C++ experience (only Maxscript)
Any help much appreciated!

might be worth starting new topic for this :slight_smile:

the error you are getting on line 5 might be cause there is nothing selected (or detected). I’m not sure how ue.get_selected_assets() method works, as it seems the documentation leaves a lot to be desired :slight_smile:

Anyway, try adding:

print(asset)

to line 4 (before error occurs, after you get selected assets), this should be list of the selected assets, if it’s empty ([ ]) or None, then there’s an issue.

Try select assets in the scene instead, see if this changes, maybe the method only registers asset selection in the scene rather than in the browser.

Thanks ex3me,

You were right about needing to select in scene rather than in content browser.
I get a new error now though!! :slight_smile:
Making a new thread/topic now and will post very shortly.

New Topic posted here: