I have a bow and arrow. I want to make the following logic for the bow:
If the attack button is pressed:
Start charging the bow, after
If the attack button is held down, wait for the button to be released, after the
Shot.
I have written the following code for this:
why if released keys next time don t work anamation RUN ?
extends CharacterBody2D @onready var anim = $AnimatedSprite2D
var speed = 5
var bow
var axe
func update():
if Input.is_action_pressed(“right”):
anim.play(“RUN”)
anim.flip_h = false
func update2():
if Input.is_action_pressed(“left”):
anim.play(“RUN”)
anim.flip_h = true
func update3():
if Input.is_action_just_released:
anim.play(“stay”)
func _physics_process(delta):
var items = [bow,axe]
var one_item = items[0]
var two_item = items[1]
for item in items:
print(" = ", item)
if Input.is_action_pressed("left"):
position.x -= 1*speed
update2()
if Input.is_action_pressed("right"):
position.x += 1*speed
update()
if Input.is_action_just_released:
update3()
move_and_slide()