0 votes

I keep getting this " error Invalid call. Nonexistent function 'get_collider' in base 'Dictionary', which is weird because I followed the docs and they used it the same say way. my code is blow.

func _input(event):
    if(Input.is_mouse_button_pressed(BUTTON_LEFT)):
        rayFrom = self.project_ray_origin(event.pos);
        rayTo = rayFrom + self.project_ray_normal(event.pos) * 100

func _fixed_process(delta):

    if(rayFrom != Vector3() && rayTo != Vector3()):
        var space_state = get_world().get_direct_space_state()
        var ray = space_state.intersect_ray(rayFrom, rayTo, [self]);

        if(!ray.empty()):
            print(ray.get_collider())
            print(ray.is_colliding())
in Engine by (271 points)

Never used it but space_state.intersect_ray returns a dictionary, not a RayCast node
https://godot.readthedocs.io/en/stable/classes/class_physicsdirectspacestate.html#class-physicsdirectspacestate-intersect-ray

I think all the collider data is in that dictionary.

My goodness. I think I was just having one of those brain fat moments because I forgot for a sec how dictionaries work :P

Please log in or register to answer this question.

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 webmaster@godotengine.org with your username.