Hi i try to use MultiMeshInstance with collision node.
The attaches script works so far but the collision shape is only applyed to the MultiMeshInstance and not to the mesh instances.
Looks like MultiMeshInstance not handels collision shapes for all instances respecting translation, scale and rotating
The applied collision shape is static and has the original transformation from the original cube.
So how add a collision shape right to a MultiMeshInstance ?
Here my small test script
extends Node
func _ready():
# create a simple box mesh
var mesh = CubeMesh.new()
mesh.size = Vector3(1,1,1)
# create multi mesh
var multiMesh = MultiMesh.new()
multiMesh.transform_format = MultiMesh.TRANSFORM_3D
multiMesh.color_format = MultiMesh.COLOR_FLOAT
multiMesh.mesh = mesh
multiMesh.instance_count = 4
var mmi = MultiMeshInstance.new()
mmi.multimesh = multiMesh;
# create collision shape
var collisionNode = StaticBody.new()
var collisionShape = CollisionShape.new()
collisionShape.shape = multiMesh.mesh.create_trimesh_shape()
collisionNode.add_child(collisionShape)
mmi.add_child(collisionNode)
add_child(mmi)
for mesh_index in range(multiMesh.instance_count):
var position = Transform().translated(Vector3(mesh_index*2, 10+2, 0)).scaled(Vector3(1,1,1))
multiMesh.set_instance_transform(mesh_index, position)
The official documentation has no info about MultiMeshInstance and using collision.
I use Godot 3.1.1