Zylann heightmap collision

Godot Version

4.4

Question

I am using the Zylann heightmap plugin. I have a CharacterBody3D player character that I want to have move along the surface of the terrain.

For some reason it’s not able to detect collision between the player character and the terrain. I would expect move_and_collide to return something when it goes through the terrain, but it never returns anything.

func _process(delta: float) -> void:
	var collision = move_and_collide(Vector3(-1,0,0) * delta)
	if collision != null:
		print(collision)

Am I missing something here? Is there a better way detect collision between a character body and a heightmap terrain object? Is there a better way in general to figure out what direction is perpendicular to the terrain at a point so I can figure out what direction the character should move in?

The Collision section in the docs you link says collision is off by default and needs to be enabled in the inspector. Have you done that?

1 Like

Yes. In fact, it is definitely able to collide with Rigidbody3D based objects (I have tested this and it works).

Is a kinematic collision a fundamentally different collision system? That move_and_collide function is supposed to return a KinematicCollision3D object.

We’re outside my experience here, so I’m speculating, but I’m assuming it returns a kinematic collision so you can do things like place a character’s feet properly.

1 Like

I think you’re right. Unfortunately it seems like it’s not returning anything at all and the character just phases through the terrain. The docs are a bit short, and digging into the source code hasn’t given me any insights so far, but I’ll keep looking.