0 votes

I have created a radial menu that is made to select different items. It uses keyboard input to allow a user to select an adjacent item that is clockwise or counterclockwise to their currently selected item. In the code and computationally this concept is represented by going left or right on an array of child nodes. The actual selection of the correct slot is perfectly functional. But the animations are messed up if the user spams the button. I have tried delaying user input using a timer but it just didn't work. The setup for the menu is that there are a series of animated sprites that serve as weapon slots who's position is in a radial configuration. They start in "closed" state where the sprite is small. Then, when a weapon is selected the animation for the slot is played telling the user that this slot is the one they have selected. Then when the user selects another weapon slot the currently used weapon slot has it's "closing" animation played. However, when the user spams the input(like if they were in a fight) then the animations go wild and multiple weapon slots take on the appearance of being selected even though they are not the currently active weapon slot. I need some help with the code that is posted below since I just can't figure out the problem. (I can post any additional information needed.)

func _physics_process(_delta):
    if Input.is_action_just_pressed("change_weapon_left") and weapon_wheel.visible:
    if Input.is_action_just_pressed("change_weapon_right") and weapon_wheel.visible:

func change_weapon(direction):
    yield(slot_sprites.get_child(selected_weapon), "animation_finished")

    if direction < 0:
        if selected_weapon == 0:
            selected_weapon = 7
            selected_weapon -= 1
        if selected_weapon == 7:
            selected_weapon = 0
            selected_weapon += 1

    yield(slot_sprites.get_child(selected_weapon), "animation_finished")
Godot version 3.4.2
in Engine by (144 points)

1 Answer

0 votes
Best answer

The first yield in change_weapons was causing the issue. After deleting it the animations worked perfectly.

by (144 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.