why i get this error?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By potatobanana

at first i thought, error cause by me go outside viewport, but still problem still happen when close to go outside viewport… can some1 explain to me why this happend? why say function in group null?
Imgur
enter image description here

:bust_in_silhouette: Reply From: jgodfrey

Nothing jumps out at me as obviously wrong there (by eye), but collider must be null. It shouldn’t be hard to find out what’s wrong by either 1) throwing in some print statements to see what’s going wrong or, better yet 2) just put a debug break point there and examine what’s in the variables…

From the docs get_slide_collison returns information about the last call to move_and_slide. From your screen shots, it’s not clear where move_and_slide is being called or how you get into your collision_effect method. Perhaps the collider instance has already been freed elsewhere in the code when you access it here?

Short of anything else, you should probably change to something like this:

if collider && collider.is_in_group("enemy"):

jgodfrey | 2020-03-07 15:13