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?

  • I've tried to duplicate the problem, but has_method() works in both cases for me, on godot 3.4.5. Maybe you could link a simplified project that has the issue?

I've tried to duplicate the problem, but has_method() works in both cases for me, on godot 3.4.5. Maybe you could link a simplified project that has the issue?

    duane Okay, I can only download 3.4.4 but it seems this was indeed some kind of bug. It works fine with 3.4.4. Thanks.