Advertisement
chris33556

hitting oildrum facing wrong way

Aug 9th, 2022
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 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.  
  15. func _process(delta):
  16. apply_gravity(delta)
  17. #jump()
  18. if Input.is_action_pressed("move_right") && isAttacking == false:
  19. movement.x = speed;
  20. $AnimatedSprite3D.play("walk");
  21. elif Input.is_action_pressed("move_left") && isAttacking == false:
  22. movement.x = -speed;
  23. $AnimatedSprite3D.play("walk");
  24. elif Input.is_action_pressed("move_up") && isAttacking == false:
  25. movement.z = -speed;
  26. $AnimatedSprite3D.play("walk");
  27. elif Input.is_action_pressed("move_down") && isAttacking == false:
  28. movement.z = speed;
  29. $AnimatedSprite3D.play("walk");
  30. else:
  31. movement.x = 0;
  32. movement.z = 0;
  33. if isAttacking == false:
  34. $AnimatedSprite3D.play("idle");
  35.  
  36. if movement.x > 0:
  37. animatedSprite.flip_h = false
  38. elif movement.x < 0:
  39. animatedSprite.flip_h = true
  40.  
  41.  
  42.  
  43. if Input.is_action_just_pressed("reverse_kick"):
  44. $AnimatedSprite3D.play("reverse_kick");
  45. isAttacking = true;
  46.  
  47. if Input.is_action_just_pressed("punch"):
  48. $AnimatedSprite3D.play("punch");
  49. isAttacking = true;
  50. $AttackArea/CollisionShape.disabled = false;
  51.  
  52. if is_on_floor() && Input.is_action_just_pressed("jump"):
  53. movement.y = jump_impulse;
  54. elif !is_on_floor():
  55. $AnimatedSprite3D.play("jumping");
  56. isAttacking = false;
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. movement = move_and_slide(movement, Vector3.UP * delta);
  65.  
  66. return movement.normalized();
  67.  
  68.  
  69.  
  70. func apply_gravity(delta):
  71. movement.y = movement.y + gravity;
  72.  
  73.  
  74. #func jump():
  75. #if is_on_floor() && Input.is_action_pressed("jump"):
  76. #isJumping = true;
  77. #movement.y = jump_impulse;
  78.  
  79.  
  80.  
  81.  
  82. func _on_AnimatedSprite3D_animation_finished():
  83. if $AnimatedSprite3D.animation == "punch":
  84. #get_node("AnimatedSprite3D").play("idle")
  85. $AttackArea/CollisionShape.disabled = true
  86. isAttacking = false
  87.  
  88.  
  89.  
  90.  
  91. # var col = get_node("CollisionShape")
  92. # get_node("AnimatedSprite3D").play("punch")
  93. # isAttacking = false;
  94. # $AttackArea/CollisionShape.disabled = true;
  95. # print (col.is_disabled())
  96.  
  97. get_node("AnimatedSprite3D").play("jumping")
  98. isAttacking = false;
  99. isJumping = false;
  100.  
  101.  
  102. func _on_AttackArea_body_entered(body):
  103. if body.has_method("handle_hit"):
  104. body.handle_hit(damage)
  105.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement