,How to use Physics2D.OverlapArea
Couldn't find an answer. How do I use them? following script:
walled = Physics2D.OverlapArea(wallCheck.position, checkArea, whatIsWall);
wallCheck is a Transform variable -> Vector A
checkArea is a Vector2 variable -> Vector B
whatIsWall is a LayerMask.
issue with this. This returns always true, no matter if it overlaps with the according layer or not. I put the object out into nirvana and it still returns always true. OverlapCircle works charmingly fine but not what I want.
Or is something wrong with my Gizmo? But I moved my Object ten million miles away from any object or Layers. It was impossible to overlap with anything....
Gizmos.DrawWireCube(wallCheck.position, checkArea);
Answer by xxmariofer · Jun 14, 2019 at 07:50 AM
DrawWireCube and OverlapArea dont take same arguments, so maybe thats your issue, ill share an example:
VectorA (0,0,0) VectorB (10,10,10) if you use overlapArea it will "create the box" with the center in point (5,5,5) since the 2 vectors are the corners, and if you use DraWireCube it will create a gizmo box with center in point (0,0,0) and size of 10 units (this case the same but in other the size of the box will be different too)
mhh okay, gizmo is certainly wrong... sounds complicated to get it right with moving objects, I will stick with OverlapBox. ^^
Your answer
Follow this Question
Related Questions
Ground Script explanation 1 Answer
Physics2D.OverlapCircle works / Physics2D.OverlapCircleNonAlloc does not work 1 Answer
Is it possible to exclude a GameObject by his tag for a Physics2D.OverlapPoint test ?, 0 Answers
Trouble with Physics2D.OverlapArea detection 2 Answers
Unity Overlap Point Causing Error 0 Answers