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

248
Visualizações
Can't get Unity Physics2D.BoxCast(NonAlloc) to register hits where RayCast works

In Unity (2019.2) I'm trying to use a boxcast on a beam weapon of width > 0. Using a raycast for this beam test works correctly, but the BoxCast returns zero results.

I'm not using any depth, distance, or layermask filters.

 colCountRay = Physics2D.RaycastNonAlloc(e.pos, Vector2.up, collsRay);

...correctly returns the hit objects, populating collsRay and setting colCountRay to the number of hit objects. But replacing that rayCast with this...

 colCountRay = Physics2D.BoxCastNonAlloc(e.pos, Vector2.right, 0, Vector2.up, collsRay);

...colCountRay is zero

I'm using this script to visualise the box cast and it's overlapping correctly...

https://answers.unity.com/questions/1156087/how-can-you-visualize-a-boxcast-boxcheck-etc.html

I've used boxcast before in another game so I'm completely stumped here! All the tested objects have 2D colliders and a kinematic RigidBody2D. Physics2D layer filters are enabled in Settings for collisions between all objects, although that shouldn't affect the boxCast results.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Looks like you are casting a box with height 0? Could you try to use a non-zero sized box for the casting, and see if that works?

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