How can I get the edge of a 3d object (mesh or collision)?, like the one in the picture attached?

The idea is to make the player hang and slide along the edge (like in Metal Gear), of any arbitrary 3d object, so I thought about using the edge, and restrict the player's movement based on that vector.

I've been looking the MeshDataTool, but I'm not sure if this tool can be used for this purpose and how to do it.

Thank you!

Godot version 4.0.1
in Engine

I'm new to the forums but I'll try to help:

You could use the AABB class to find to the coordinates of the top plane of the object (as shown below in the getupwardsplane function).

This is where I think it gets tricky, trying to figure out when you should let the object in question fall or stick to the edge of the wall. One way you could do it is by having a collision box and detecting collision, and figuring out the point of collision, for example using CharacterBody3D's `get_slide_position()`, and getting the `.position` attribute from that.

Sample Code (not tested):

``````func get_upwards_plane():
mesh = get_node(mesh_path).get_aabb() # get the bounding box of the mesh
corner_1_pos = mesh.position # these are Vector3s
corner_2_pos = mesh.end
corner_1_pos.y = corner_2_pos.y # getting the top 2d plane

func is_collision_in_plane():
collision_pos = self.get_slide_collision().position
if is_inside_of_plane(): # this would be several if statements if the position is inside/on top of the coords of the two corner_pos
velocity.y == 0 # sample of cancelling velocity on the y to sit on the edge
``````
by (50 points)
selected by

this looks like it could be!

thank you very much, ill study the AABB class and will try to figure it out!