Advertisement
chris33556

simple movement / combo test problem scene

Nov 28th, 2022 (edited)
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 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.  
  13. movement.x = speed * Input.get_axis("ui_left", "ui_right")
  14. movement.z = speed * Input.get_axis("ui_up", "ui_down")
  15. $AnimatedSprite3D.play("walk")
  16.  
  17. if movement.x == 0 and movement.z == 0:
  18. $AnimatedSprite3D.play("idle")
  19.  
  20.  
  21. if Input.is_action_just_pressed("attack") && AttackPoints == 3:
  22. $AttackResetTimer.start()
  23. isAttacking == true
  24. $AnimatedSprite3D.play("Attack_1")
  25. AttackPoints = AttackPoints - 1
  26.  
  27.  
  28. elif Input.is_action_just_pressed("attack") && AttackPoints == 2:
  29. $AttackResetTimer.start()
  30. $AnimatedSprite3D.play("Attack_2")
  31. AttackPoints = AttackPoints - 1
  32.  
  33.  
  34. elif Input.is_action_just_pressed("attack") && AttackPoints == 1:
  35. $AttackResetTimer.start()
  36. $AnimatedSprite3D.play("Attack_3")
  37. AttackPoints = AttackPoints - 1
  38.  
  39.  
  40.  
  41. var motion = movement.normalized() * speed
  42.  
  43.  
  44.  
  45. movement = move_and_slide(movement * delta)
  46.  
  47.  
  48. func _on_AnimatedSprite3D_animation_finished():
  49. if $AnimatedSprite3D.animation == "Attack_1" || $AnimatedSprite3D.animation == "Attack_2":
  50. $AnimatedSprite3D.play("idle")
  51. elif $AnimatedSprite3D.animation == "Attack_3":
  52. $AnimatedSprite3D.play("idle")
  53. AttackPoints = 3
  54.  
  55.  
  56. func _on_AttackResetTimer_timeout():
  57. AttackPoints = 3
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement