Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | vonflyhighace2 | |
Old Version | Published before Godot 3 was released. |
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())
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.
eons | 2016-12-30 01:05
My goodness. I think I was just having one of those brain fat moments because I forgot for a sec how dictionaries work
vonflyhighace2 | 2016-12-30 02:29