Advertisement
chris33556

alternative_movement_system

Dec 26th, 2022
44
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. onready var animatedSprite = $AnimatedSprite3D
  3. var isAttacking = false
  4. var movement = Vector3(0, 0, 0)
  5. var speed = 5
  6. var Direction = "Left"
  7. export (int) var damage := 10
  8. var AttackPoints = 3
  9. var velocity = Vector3.ZERO
  10.  
  11. func _physics_process(delta):
  12. velocity = Vector3.ZERO
  13. if Input.is_action_pressed("ui_right"):
  14. velocity.x += 1
  15. if Input.is_action_pressed("ui_left"):
  16. velocity.x -= 1
  17. if Input.is_action_pressed("ui_down"):
  18. velocity.z += 1
  19. if Input.is_action_pressed("ui_up"):
  20. velocity.z -= 1
  21.  
  22.  
  23. if Input.is_action_just_pressed("attack") && AttackPoints == 3:
  24.  
  25. isAttacking == true
  26. $AnimatedSprite3D.play("Attack_1")
  27. AttackPoints = AttackPoints - 1
  28.  
  29.  
  30. elif Input.is_action_just_pressed("attack") && AttackPoints == 2:
  31.  
  32. $AnimatedSprite3D.play("Attack_2")
  33. AttackPoints = AttackPoints - 1
  34.  
  35.  
  36. elif Input.is_action_just_pressed("attack") && AttackPoints == 1:
  37. $AnimatedSprite3D.play("Attack_3")
  38. AttackPoints = AttackPoints - 1
  39.  
  40.  
  41.  
  42. var motion = movement.normalized() * speed
  43.  
  44.  
  45.  
  46. movement = move_and_slide(velocity * speed)
  47.  
  48.  
  49. func _on_AnimatedSprite3D_animation_finished():
  50. if $AnimatedSprite3D.animation == "Attack_1" || $AnimatedSprite3D.animation == "Attack_2":
  51. $AnimatedSprite3D.play("idle")
  52. elif $AnimatedSprite3D.animation == "Attack_3":
  53. $AnimatedSprite3D.play("idle")
  54. AttackPoints = 3
  55.  
  56. func _on_AttackResetTimer_timeout():
  57. AttackPoints = 3
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement