0
\$\begingroup\$

So my problem is this:

I have a block, which is used as a "pointer block" to show where a block will be spawned. It will be green if it isn't colliding anyone, meaning you can spawn a block. It gets red when it's colliding with something.

The pointer block is a trigger.

OnTriggerEnter gets called when the collider touches another collider. I want to know when another collider is in my pointer block, not when something is just on the edge of the colldier.

https://www.youtube.com/watch?v=0yNqSJ3yAxA&feature=youtu.be

\$\endgroup\$
0

2 Answers 2

1
\$\begingroup\$

For 2D you can try Physics2d Overlap Circle or for 3d try Physics.OverlapBox()

Links:

https://docs.unity3d.com/ScriptReference/Physics2D.OverlapCircle.html

https://docs.unity3d.com/ScriptReference/Physics.OverlapBox.html

\$\endgroup\$
1
\$\begingroup\$

You have three options

You can shrink the collider of the pointer ever so slightly that it doesn't trigger from being adjacent.

Or

You can use Physics2D.OverlapCircle() or Physics.OverlapBox()

Or

You can use the Physics Matrix to exclude problem objects like terrain from the pointer interaction

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .