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

244
Views
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 answers
Answer question

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 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!