Download

Set collision complexity for StaticMesh assets using Python.

I have a bunch on StaticMeshes I would like to use one type of collision complexity, and there is another bunch, where I want to use another… hundreds more coming…
So setting up the default complexity in the Project settings is not an option.

I found this articleto start my Python journey.

So I wrote similar scripts to change anim retarget sources on animation sequences. They worked fine.


import unreal

#create unreal class instances
editor_util = unreal.EditorUtilityLibrary()

# get the selected assets
selected_assets = editor_util.get_selected_assets()

for asset in selected_assets:
     asset.set_editor_property("retarget_source","my_retarget_name")

So I thought if I change the last line:


asset.set_editor_property("collision_complexity","SimpleAndComplex")

would work. I know I am a bit optimistic about this script working,
because I have not found the Python property here, but I was hoping it is just in another class, and Python is
just going to find it somehow…

Well I was wrong, I guess I have to do some more to get it work.

I am getting these on screen after running the script in the editor.



LogPython: Error: Traceback (most recent call last):
LogPython: Error: File "<string>", line 13, in <module>
LogPython: Error: Exception: StaticMesh: Failed to find property 'collision_complexity' for attribute 'collision_complexity' on 'StaticMesh'

Am I missing out something?
If not is there a workaround?

Did you ever figure this out? I just need to get the current value of CollisionComplexity.


MeshPath = '/Game/Obj/M10/Mesh/' StaticMesh_mesh_list = get_path_all_asset(MeshPath, unreal.StaticMesh) for i, name in enumerate(StaticMesh_mesh_list): Body = name.get_editor_property('body_setup') Body.set_editor_property('collision_trace_flag', unreal.CollisionTraceFlag.CTF_USE_COMPLEX_AS_SIMPLE) name.set_editor_property('body_setup', Body)

https://answers.unrealengine.com/questions/922729/python-eneble-usecomplexassimple-collision-for-sta.html