#Get collider from a shape cast / collider_id?

4 messages · Page 1 of 1 (latest)

empty maple
#

I have reimplemented some stuff from ShapeCast3D, using a combination of the direct physics stats's cast_motion and get_rest_info calls. get_rest_info being the important part here. It returns a collider ID, but no collider node reference. Looking at the godot source code, they have the following function to go from int collider_id -> Object:

Object *ShapeCast3D::get_collider(int p_idx) const {
    ERR_FAIL_INDEX_V_MSG(p_idx, result.size(), nullptr, "No collider found.");

    if (result[p_idx].collider_id.is_null()) {
        return nullptr;
    }
    return ObjectDB::get_instance(result[p_idx].collider_id);
}

so the function is ObjectDB::get_instance.

Is this able to be called from gdscript? Or is it just not possible for me to get the Object collided with by a shapecast without using a ShapeCast3D node?

empty maple
#

WAHOO