Get intersect_ray() collision position (solved)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mstfacmly
:warning: Old Version Published before Godot 3 was released.

I’m trying to get some ledge detection going on a KinematicBody in which I have a collision ray going to a target.

if wrun == "vert":
	var col_top = ds.intersect_ray(ledgecol,ptarget);
	if !col_top.empty():
		ledge_col = col_top ;
		return ledge_col ;

I want to get the Y position of where the collision hits so that I can check against the player’s position, but I can’t seem to call on get_contact_collider_pos() or any similar function. Does anybody have any ideas?

ds is called by:

ds = get_world().get_direct_space_state()
:bust_in_silhouette: Reply From: eons

That method is not documented but returns a Dictionary, I guess is the same as the 2D one (which is documented).

The dictionary should be:

{position, normal, shape, metadata, collider_id, collider, rid}

So you may want to do col_top.position.

Docs for Physics2DDirectSpaceState

I knew the answer was simple to catch! Thanks for the answer!

mstfacmly | 2017-09-18 04:13