Parameter function says parameter isn't used, while it actually is

Godot Version

4.1.1

Question

I’m using a parameter function to check for ranges of velocity in my character, in order to update the animation tree. For some reason the ‘path’ part of the parameter function says its not in use, even though it’s used twice. Am I just understanding parameter functions wrong, or what’s going on?

boolean values are copied, if you intend to pass in a “path” variable to be updated this will not work as it does nothing to the original, only edits the copies. Might be better to use keyword return

func get_vel_anim(range_start: int, range_end: int) -> bool:
    return int(velocity.y) in range(range_start, range_end)

Or change your path type to be the AnimationTree, which is referenced instead of copied.

func get_vel_anim(range_start: int, range_end: int, path: AnimationTree) -> void:
    var value: bool = int(velocity.y) in range(range_start, range_end)
    path.set("parameters/jumping", value)

Thank you a lot ! I’m still new to coding and didn’t even know what return was lol

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.