Hello,
I stumbled across a strange issue.
A custom class contains the function
func do_something(thing):
#code
Now I use a collision detection which checks if the collider has this function.
func _on_body_entered(body):
if body.has_method("do_something"):
#code
This works fine. However, there is one instance where I use the same class but with slight modifications. So the original function do_something()
wouldn't work and I need to override it:
func do_something(thing):
if some_condition == true:
.do_something(thing)
So the colider does contain a function do_something()
. But strangely, the has_method()
only works if condition == true
. If condition == false
, then body.has_method("do_something")
is also false.
I don't want to write a new method and then have the other scripts account for that method as well.
Is this intended behavior, and if so, how can I make it recognize the method that is actually present?