How do I activate this animation player on right-click?

DetonatressDetonatress Posts: 49Member

I have several animation players assigned to one character, and I'm trying to activate an animation from one of them in the input event of the character.

func _input(event):
    if  Input.is_action_pressed("R_punch"):
        $"TSBM Drone/DroneRPunchANIM".play("Drone_PUNCH_R")

My settings have right punch set to mouse right-click (device 0).
The problem is... when I right-click, nothing happens. Why?

Answers

  • vinpogovinpogo Posts: 24Member

    taken from the official godot docs: https://docs.godotengine.org/en/stable/tutorials/inputs/input_examples.html

    it seems you should only change your if statement to this: if event.is_action_pressed("R_punch"):

    As far as i understand, Input.is_action_pressed should be used inside the process functions.

  • DetonatressDetonatress Posts: 49Member
    edited June 29

    @vinpogo said:
    taken from the official godot docs: https://docs.godotengine.org/en/stable/tutorials/inputs/input_examples.html

    it seems you should only change your if statement to this: if event.is_action_pressed("R_punch"):

    As far as i understand, Input.is_action_pressed should be used inside the process functions.

    I don't know what I did but these now work for some reason:

    func _input(event):
        if  Input.is_action_pressed("R_Punch"):
            $"TSBM Drone/DroneRPunchANIM".play("Drone_PUNCH_R")
    
        if  Input.is_action_pressed("L_Punch"):
            $"TSBM Drone/DroneLPunchANIM".play("Drone_PUNCH_L")
    


    I am confused since they're pretty much same codes.

  • vinpogovinpogo Posts: 24Member

    strange it looks like thew exact same code... But if it works, it works :)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file