How can I fix this: invalid call. nonexistent function 'move_toward' in base 'bool' ?

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

enter link description here

Hard to say without some code to look at. As the error says, you’re trying to call a move_toward() function on a bool type. And, since a bool type doesn’t have such a function, you get that error.

You’ll need to post some code for additional input.

jgodfrey | 2023-03-15 23:37

I have tried attaching a image but it doesn’t show up. So I use Hyperlinks instead.enter link description here

win0908 | 2023-03-15 23:41

:bust_in_silhouette: Reply From: jgodfrey

So, in Godot 3.x, move_and_slide() returned a Vector2. However, in Godot 4, move_and_slide returns a bool. So, while your knockback variable started out as a Vector2, at this line of code, it is replaced with a bool.

knockback = move_and_slide()

Assuming you’re not interested in the bool return value of move_and_slide, the simple fix is to simply change the above to:

move_and_slide()

See the docs here for more details:

Thank you so much

win0908 | 2023-03-15 23:51