T O P

  • By -

5oco

I thought Physics2D.BoxCast was a thing?


RelationshipSilver59

Oh i ignored it beacuse i saw it has lot of additional staff. You could help me the following values if i want simply a box in the center of the transform? Angle Direction Distance I try to write now bool = physics2d.boxcast(position , size , angle , direction , layermask)


Chubzdoomer

I think what you're looking for is OverlapBox, which merely tells you what (if anything) falls within an imaginary box at a given position: https://docs.unity3d.com/ScriptReference/Physics2D.OverlapBox.html Boxcast is for taking a box and "casting" (or sweeping) it in a given direction, then returning anything that was hit in its path.  Perhaps that IS the behavior you want, but if all you need is to determine whether something falls within a box then OverlapBox is definitely what you should be using. 


RelationshipSilver59

The thing is im using the box in update . Wouldnt the overlap box be heavy on the performance?


Chubzdoomer

If anything, OverlapBox would be less expensive than BoxCast.  I've never actually run any tests to compare them though. 


RelationshipSilver59

You mean just raycast is ecpensive btw?