Advertisement
chris33556

alternative script movement with combo

Dec 1st, 2022
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 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 = 5
  7. var Direction = "Left"
  8. export (int) var damage := 10
  9. var AttackPoints = 3
  10. var velocity = Vector3.ZERO
  11.  
  12. func _physics_process(delta):
  13. velocity = Vector3.ZERO
  14. if Input.is_action_pressed("ui_right"):
  15. velocity.x += 1
  16. if Input.is_action_pressed("ui_left"):
  17. velocity.x -= 1
  18. if Input.is_action_pressed("ui_down"):
  19. velocity.z += 1
  20. if Input.is_action_pressed("ui_up"):
  21. velocity.z -= 1
  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(velocity * speed)
  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.  
  57. func _on_AttackResetTimer_timeout():
  58. AttackPoints = 3
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement