Advertisement
Guest User

Untitled

a guest
Apr 19th, 2025
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. private void OnTriggerEnter2D(Collider2D collision)
  2. {
  3.  
  4. //Debug.Log("currently colliding with " + collision.gameObject.tag);
  5.  
  6.  
  7. if (collision.gameObject.tag == "punch" || collision.gameObject.tag == "kick" || collision.gameObject.tag == "upperCut")
  8. {
  9. if (beingAttacked == true)
  10. {
  11. currentCombo++;
  12. comboNumbers.SetText(currentCombo.ToString());
  13.  
  14. shakeOffset += .1f;
  15.  
  16.  
  17.  
  18. //Debug.Log("supposed to shake");
  19. generateRandomOffset();
  20.  
  21. Vector2 offsetAmount = new Vector2(xOffset, yOffset);
  22. transform.position = offsetAmount + new Vector2(transform.position.x, transform.position.y);
  23.  
  24. StartCoroutine(attackVibe());
  25.  
  26. }
  27. }
  28.  
  29.  
  30. if (collision.gameObject.tag == "punch")
  31. {
  32.  
  33. if(beingAttacked == false)
  34. {
  35. Debug.Log("being attacked by " + collision.gameObject + " tag is: " + collision.gameObject.tag);
  36. //Debug.Log("kai hit enemy");
  37. rB.AddForce(new Vector2(punchForce, 0));
  38. StartCoroutine(delay(stunTimer));
  39. beingAttacked = true;
  40. }
  41.  
  42. //rB.AddForce(new Vector2(punchForce, 0));
  43. }
  44.  
  45. if(collision.gameObject.tag == "wall")
  46. {
  47. //force = (-rB.velocity);
  48. //Debug.Log("wall trigger enter");
  49. rB.AddForce(new Vector2(-punchForce, 0));
  50. }
  51.  
  52.  
  53.  
  54. if(collision.gameObject.tag == "upperCut")
  55. {
  56.  
  57. if (beingAttacked == false)
  58. {
  59. Debug.Log("sui hit enemy");
  60.  
  61. beingAttacked = true;
  62. rB.AddForce(new Vector2(0, uppercutForce));
  63. StartCoroutine(delay(stunTimer));
  64. //beingAttacked = true;
  65. }
  66.  
  67. //rB.AddForce(new Vector2(0, uppercutForce));
  68. }
  69.  
  70.  
  71. if (collision.gameObject.tag == "ceiling")
  72. {
  73. //Debug.Log("ceiling trigger enter");
  74. rB.AddForce(new Vector2(0, -uppercutForce));
  75. }
  76.  
  77.  
  78. if (collision.gameObject.tag == "kick")
  79. {
  80.  
  81. if (beingAttacked == false)
  82. {
  83.  
  84. rB.AddForce(new Vector2(0, kickForce));
  85. StartCoroutine(delay(stunTimer));
  86. beingAttacked = true;
  87. }
  88.  
  89. //rB.AddForce(new Vector2(0, kickForce));
  90. }
  91.  
  92. if (collision.gameObject.tag == "floor")
  93. {
  94. //Debug.Log("floor trigger enter");
  95. rB.AddForce(new Vector2(0, -kickForce));
  96. }
  97.  
  98.  
  99.  
  100. if(collision.gameObject.tag == "EnemyOrigin" && beingAttacked == true)
  101. {
  102. //this shoudl be set when the enemy returns back to position (uhhhhhhhhhhhhhhhh)
  103. currentCombo = 0;
  104. comboNumbers.SetText(currentCombo.ToString());
  105. shakeOffset = .5f;
  106.  
  107. beingAttacked = false;
  108. }
  109.  
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement