Advertisement
chris33556

combo_string_test

Nov 27th, 2022
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. extends KinematicBody
  2.  
  3. onready var animatedSprite = $AnimatedSprite3D
  4. var isAttacking = false
  5. var movement = Vector3(0, 0, 0)
  6. var speed = 150
  7. var Direction = "Left"
  8. export (int) var damage := 10
  9. var AttackPoints = 3
  10.  
  11. func _physics_process(delta):
  12. if Input.is_action_pressed("ui_right") && isAttacking == false:
  13. movement.x = speed;
  14. elif Input.is_action_pressed("ui_left") && isAttacking == false:
  15. movement.x = -speed;
  16. elif Input.is_action_pressed("ui_up") && isAttacking == false:
  17. movement.z = -speed;
  18. elif Input.is_action_pressed("ui_down") && isAttacking == false:
  19. movement.z = speed;
  20. else:
  21. movement.x = 0
  22.  
  23.  
  24. if Input.is_action_just_pressed("attack") && AttackPoints == 3:
  25.  
  26. isAttacking == true
  27. $AnimatedSprite3D.play("Attack_1")
  28. AttackPoints = AttackPoints - 1
  29.  
  30.  
  31. elif Input.is_action_just_pressed("attack") && AttackPoints == 2:
  32.  
  33. $AnimatedSprite3D.play("Attack_2")
  34. AttackPoints = AttackPoints - 1
  35.  
  36.  
  37. elif Input.is_action_just_pressed("attack") && AttackPoints == 1:
  38. $AnimatedSprite3D.play("Attack_3")
  39. AttackPoints = AttackPoints - 1
  40.  
  41.  
  42.  
  43. var motion = movement.normalized() * speed
  44.  
  45.  
  46.  
  47. movement = move_and_slide(movement * delta)
  48.  
  49.  
  50. func _on_AnimatedSprite3D_animation_finished():
  51. if $AnimatedSprite3D.animation == "Attack_1" || $AnimatedSprite3D.animation == "Attack_2":
  52. $AnimatedSprite3D.play("idle")
  53. elif $AnimatedSprite3D.animation == "Attack_3":
  54. $AnimatedSprite3D.play("idle")
  55. AttackPoints = 3
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement