if Input.is_action_pressed("super"):
animator.play("attack_3")
animator.flip_h = false
isattacking = true
$attackarea_3/CollisionShape2D.disabled = false;
if Input.is_action_just_pressed("Run"):
SPEED = SPEED * 2.5
if Input.is_action_just_released("Run"):
SPEED = SPEED / 2.5
pass
pass
move_and_slide()
pass # Replace with function body.
func start(pos):
position = pos
show()
pass # Replace with function body.
func _on_animated_sprite_2d_animation_finished():
if $PlayerSprite2D.animation == “attack_1”:
isattacking = false;
$attackarea/CollisionShape2D.disabled = true;
$attackarea_2/CollisionShape2D.disabled = true;
pass # Replace with function body.
pass # Replace with function body.
func _on_animated_sprite_2d_animation_finished3():
if $PlayerSprite2D.animation == “attack_3”:
isattacking = false;
$attackarea_3/CollisionShape2D.disabled = true;
pass # Replace with function bod
alright so this is the attacks and movement code wasd is movement and arrow keys are attacks the problem im having is if you press the d key and press the w key you move down and to the right but if you press the s key you move up and to the right same with the a key the other problem is if you attack and move the animation gets canceled but the attack area stays active how on earth do i fix this
It’s difficult to read the code without code formatting, could you try pasting it again but use the </> button to insert a block. It will look like this
```
type or paste code here
```
Then press ctrl+v to paste between the ticks ```
One thing I’m seeing is this code applies velocity in two separate if statements, one more conventional, then again with attack checks.
# conventional, very similar to template code
var direction = Input.get_axis("move_left", "move_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
# attempting to handle attacks
if Input.is_action_pressed("move_left") && isattacking == false && movey == false:
movex = true
velocity.x = -SPEED
animator.play("walk");
animator.flip_h = true
elif Input.is_action_just_released("move_left"):
movex = false
I would bet reducing this code would solve your issues, as attacks and movement are separate actions they will behave better when separated. But again with proper formatting it will be possible to tell.
and the reason there are two velocities is cause i want the character to move up down left and right so there is no jump but movement on the y and x axis