-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFixPhysicsPropsCollisions.py
43 lines (30 loc) · 1.57 KB
/
FixPhysicsPropsCollisions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
This script is used to fix physics collision properties of prop physics actors in a game level.
Usage:
- Call the `fix_physics_props_collision()` function to fix physics
collision for prop physics actors in the current level.
Functions:
- `fix_physics_props_collision()`: Fixes the physics collision properties of prop physics actors in the current level.
Note:
- The script assumes the presence of the `get_component_by_class()` function.
- The script currently does not handle collision with characters and bots. This functionality is marked as a TODO.
"""
import unreal
from Common import get_component_by_class
def fix_physics_props_collision():
ctf_use_default = int(unreal.CollisionTraceFlag.CTF_USE_DEFAULT.value)
for actor in unreal.EditorLevelLibrary.get_all_level_actors():
name: str = actor.get_name()
if not name.startswith("prop_physics"):
continue
print(f"Setup physics collision for: {actor.get_name()}")
component = get_component_by_class(actor, unreal.StaticMeshComponent)
actor.set_mobility(unreal.ComponentMobility.MOVABLE)
static_mesh = component.static_mesh
unreal.Cloud9ToolsLibrary.set_collision_complexity(static_mesh, ctf_use_default)
unreal.EditorStaticMeshLibrary.remove_collisions(static_mesh)
unreal.EditorStaticMeshLibrary.add_simple_collisions(static_mesh, unreal.ScriptingCollisionShapeType.NDOP26)
component.set_simulate_physics(True)
# TODO: Remove collision with character and bots
if __name__ == '__main__':
fix_physics_props_collision()