Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

503
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda