How to add trimesh collision to multiple Meshinstances at once

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ZambaBoeee

I have a (environment) scene with 77 mesh instance to which i want the player to be able to collide with.
Problem is, how do i automate the process of adding trimesh collision to each and every mesh.

:bust_in_silhouette: Reply From: Wakatta

3 Steps …

  1. Use tool mode
  2. Loop through SceneTree
  3. Create collisions


tool extends EditorScript

func _run():
	for child in get_scene().get_children():
		if child is MeshInstance:

The above code assumes a few things like all 77 MeshInstances are a child of the scene root which you can get over by creating a recursive function to get all nodes.

In the Script Editor press File > Run