Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

504
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda