Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OnCollisionEnter2D(Collision2D collision)
- {
- ContactPoint2D contact = collision.GetContact(0);
- Vector2 hitDir = -contact.normal;
- hitDir.Normalize();
- float dotUp = Vector2.Dot(hitDir, Vector2.up);
- if (dotUp > 0f)
- //bas
- else
- //top
- }
- ---------------------------------------------------
- //trigger
- void OnTriggerEnter2D(Collider2D other)
- {
- Vector2 hitDir =
- ((Vector2)transform.position - other.ClosestPoint(transform.position)).normalized;
- float dotUp = Vector2.Dot(hitDir, Vector2.up);
- if (dotUp > 0f)
- //bas
- else
- //top
- }
Advertisement
Add Comment
Please, Sign In to add comment