Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

501
Views
How do I detect which side of the object I exited from on OnCollisionExit2D()

I can detect which side of an object I collide with however I need to reset some variables when I exit a collision. How do I tell which side of an object I exited from? (ie if I have collided with the ground then I collide with a wall on the left but then move right I need to know if I have exited from the collision with the wall or if I exited from the collision with the ground.)

Note the blocks I am colliding with are both walls and ground so I can't use layer names etc.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

1.

I really struggle to understand the question, but a common trick is you actually have a number of colliders on the object.

Say it is a cube.

Instead of having one cube-shaped collider, in fact have SIX colliders!

(So, basically flat ones, whatever technique you want to use.)

Depending on your situation, you then know exactly what collided with what.

I really don't understand the question, but I think you're wanting to know, of the six, which was the "last one" touched.

Of course, that is easy to achieve as a basic programming matter, just figure out which of the six was touched last.†

2.

Note that as BugFinder explains. As you "leave", simply look at your new velocity, that is to say look at the direction of your velocity.

Obviously, that will instantly tell you "what part" of the other object, you must have bounced off.

Note too that indeed you can simply cast backwards from your new velocity, and see what you hit - that is likely what bounced you!

--

† beware that PhysX can matt things in to the same frame, the idea of what was "touched last" when you're in a corner can be problematic. This is why "2" is a common approach.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!