How to get normal at a point on CollisionShape3D or StaticBody3D?

Godot Version

4.4

Question

I have a simple game with a piece of terrain modeled as a StaticBody3D with a CollisionShape3D and a concave polygon as the shape. It is the green hills in this screenshot.

What I want is to find the normal at a certain point on this terrain. Ideally I put in X and Z coordinates and get back a Vector3 representing the angle relative to some universal direction. However, I am finding it hard to find something like this.

What’s the best way to get a value like this? Thanks!

You should use a Raycast (either in code, or as a node). You can filter the cast to only collide with your desired body, either via a collision channel or the filter list.

The normal can be extracted from result.normal

1 Like

This looks exactly like what I’m looking for. Thank you!