0 votes

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 getcontactcollider_pos() or any similar function. Does anybody have any ideas?

ds is called by:

ds = get_world().get_direct_space_state()
in Engine by (29 points)
edited by

1 Answer

+1 vote
Best answer

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

by (7,946 points)
selected by

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.