Create_trimesh_collision() not behaving right

Godot Version

<4.1.3 →


create_trimesh_collision() doesn’t seem to inherent the properties of the node that it is in. I am building a dynamically shaped platform that moves, so the create_trimesh_collision is essential. However my player will slide on it even if it’s a child of a RigidBody. Not sure how to solve this.

so from my understanding it’s creating the trimesh_collision as part of a child of a staticbody3d node… what the? why?

In case anyone is wondering. I found a work around by doing this:

var rigid_body =
var static_body = mesh_instance.get_child(0)
static_body.replace_by(rigid_body, true)

You could use any of the create_*_shape() methods in Mesh depending on what Shape3D you need: Mesh.create_trimesh_shape() and Mesh.create_convex_shape()


extends RigidBody3D

@onready var mesh_instance_3d: MeshInstance3D = $MeshInstance3D
@onready var collision_shape_3d: CollisionShape3D = $CollisionShape3D

func _ready() -> void:
func update_collision_shape() -> void:
	collision_shape_3d.shape = mesh_instance_3d.mesh.create_trimesh_shape()

Thanks! That’s a lot cleaner.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.