Eonirr

Untitled

Jan 6th, 2026 (edited)
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. void OnCollisionEnter2D(Collision2D collision)
  2. {
  3. ContactPoint2D contact = collision.GetContact(0);
  4.  
  5. Vector2 hitDir = -contact.normal;
  6. hitDir.Normalize();
  7.  
  8. float dotUp = Vector2.Dot(hitDir, Vector2.up);
  9.  
  10. if (dotUp > 0f)
  11. //bas
  12. else
  13. //top
  14. }
  15. ---------------------------------------------------
  16. //trigger
  17.  
  18. void OnTriggerEnter2D(Collider2D other)
  19. {
  20. Vector2 hitDir =
  21. ((Vector2)transform.position - other.ClosestPoint(transform.position)).normalized;
  22.  
  23. float dotUp = Vector2.Dot(hitDir, Vector2.up);
  24.  
  25. if (dotUp > 0f)
  26. //bas
  27. else
  28. //top
  29. }
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment