Advertisement
chris33556

update_beatem up game 14_08_22

Aug 14th, 2022
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. extends KinematicBody
  2.  
  3. onready var animatedSprite = $AnimatedSprite3D
  4.  
  5. var movement = Vector3();
  6. var up = Vector3();
  7. var speed = 70;
  8. var isAttacking = false;
  9. var isJumping = false;
  10. var gravity = -30;
  11. var jump_impulse = 320
  12. onready var AttackArea = $AttackArea
  13. export (int) var damage := 10
  14. var direction = Vector3.ZERO
  15.  
  16. func _process(delta):
  17. apply_gravity(delta)
  18. #jump()
  19. if Input.get_action_strength("move_right") && isAttacking == false:
  20. movement.x = speed;
  21. $AnimatedSprite3D.play("walk");
  22. isAttacking = false;
  23. $AttackArea/CollisionShape.disabled = true
  24. elif Input.get_action_strength("move_left") && isAttacking == false:
  25. movement.x = -speed;
  26. $AnimatedSprite3D.play("walk");
  27. isAttacking = false;
  28. $AttackArea/CollisionShape.disabled = true
  29. elif Input.get_action_strength("move_up") && isAttacking == false:
  30. movement.z = -speed;
  31. $AnimatedSprite3D.play("walk");
  32. isAttacking = false;
  33. $AttackArea/CollisionShape.disabled = true
  34. elif Input.get_action_strength("move_down") && isAttacking == false:
  35. movement.z = speed;
  36. $AnimatedSprite3D.play("walk");
  37. isAttacking = false;
  38. $AttackArea/CollisionShape.disabled = true
  39. else:
  40. movement.x = 0;
  41. movement.z = 0;
  42. if isAttacking == false:
  43. $AnimatedSprite3D.play("idle");
  44. isAttacking = false;
  45. $AttackArea/CollisionShape.disabled = true
  46.  
  47. if movement.x > 0:
  48. animatedSprite.flip_h = false
  49. elif movement.x < 0:
  50. animatedSprite.flip_h = true
  51.  
  52.  
  53.  
  54. if Input.get_action_strength("reverse_kick"):
  55. $AnimatedSprite3D.play("reverse_kick");
  56. isAttacking = true;
  57.  
  58. if Input.get_action_strength("punch"):
  59. $AnimatedSprite3D.play("punch");
  60. isAttacking = true;
  61. $AttackArea/CollisionShape.disabled = false;
  62.  
  63. if Input.get_action_strength("throw") and Input.get_action_strength("move_right"):
  64. $AnimatedSprite3D.play("Throw");
  65. isAttacking = true;
  66. $AttackArea/CollisionShape.disabled = true
  67.  
  68. if Input.get_action_strength("throw") and Input.get_action_strength("move_left"):
  69. $AnimatedSprite3D.play("Throw");
  70. isAttacking = true;
  71. $AttackArea/CollisionShape.disabled = true
  72.  
  73. if is_on_floor() && Input.get_action_strength("jump"):
  74. movement.y = jump_impulse;
  75. elif !is_on_floor():
  76. $AnimatedSprite3D.play("jumping");
  77. isAttacking = false
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. movement = move_and_slide(movement, Vector3.UP * delta);
  85.  
  86. return movement.normalized();
  87.  
  88.  
  89.  
  90. func apply_gravity(delta):
  91. movement.y = movement.y + gravity;
  92.  
  93.  
  94. #func jump():
  95. #if is_on_floor() && Input.is_action_pressed("jump"):
  96. #isJumping = true;
  97. #movement.y = jump_impulse;
  98.  
  99.  
  100.  
  101.  
  102. func _on_AnimatedSprite3D_animation_finished():
  103. if $AnimatedSprite3D.animation == "punch":
  104. #get_node("AnimatedSprite3D").play("idle")
  105. $AttackArea/CollisionShape.disabled = true
  106. isAttacking = false
  107.  
  108.  
  109.  
  110.  
  111. # var col = get_node("CollisionShape")
  112. # get_node("AnimatedSprite3D").play("punch")
  113. # isAttacking = false;
  114. # $AttackArea/CollisionShape.disabled = true;
  115. # print (col.is_disabled())
  116.  
  117. get_node("AnimatedSprite3D").play("jumping")
  118. isAttacking = false;
  119. isJumping = false;
  120.  
  121. #func punch():
  122. # var enemies = AttackArea.get_overlapping_bodies()
  123. # for enemy in enemies:
  124. # if enemy.has_method("being_hit"):
  125. # enemy.being_hit()
  126.  
  127. func _on_AttackArea_body_entered(body):
  128. if body.has_method("handle_hit"):
  129. body.handle_hit(damage)
  130.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement