Ray collisions and group nulls

Godot Version

Godot 4.2


Hey Y’all! Programming a path finding system with ray collisions. Currently, before any checks are done I run an if statement to check if the ray is colliding. If it is, it goes forward and checks the colliders groups to evaluate what to do.

Currently, I have a consistent issue where on occasion when calling to get groups I will get a crash as it says "Attempt to call function ‘get_groups’ in base ‘null instance’ on null instance. "

I PRESUME that means that there are no groups with the collider. I want to know f there’s a way to check for null groups. I thought ray.get_collider().get_groups().is_empty(): would work but apparently not. Thanks for your help!

no, it’s just the script/node who call the get_groups doesnt exists or not ready

the get_collider() can returns null, so you will need to check if it’s null or not by placing it to a variable first

the other reason could be your ray doesnt exist which is why it’s null