Advertisement
Guest User

Untitled

a guest
May 6th, 2025
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. // ENEMY STATE (FREEFALL)
  2. public override void Coll_Collision(Collision2D collision) // *OnCollisionEnter2D
  3. {
  4.  
  5. if (collision.gameObject.tag == "HITBOX_WALL")
  6. {
  7. wall_hits++;
  8.  
  9. Hitbox_Wall wall = enemy.get_hitbox_wall_data();
  10.  
  11. // ISSUE BELOW ///
  12.  
  13. // When it hits the wall, calculate speed and apply velocity.
  14. Vector2 impact_velocity = -collision.relativeVelocity; // Get the enemy's impact velocity from the wall
  15. float impact_speed = impact_velocity.sqrMagnitude;
  16.  
  17. Debug.Log(impact_speed);
  18.  
  19. // If the speed at which the enemy hits the player is
  20. if (impact_speed > wall.wall_damagable_speed)
  21. {
  22. wall.DealDamage();
  23. }
  24.  
  25. // Apply velocity from the ground
  26. enemy.get_rigidBody2D().velocity = impact_velocity * wall.elasticity * wall.coldir;
  27.  
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement