Home > Net >  Ray Perception Sensor 2D gizmos not detecting collision
Ray Perception Sensor 2D gizmos not detecting collision

Time:04-06

If I make a new scene with 3d sphere and cube and make the sphere has Ray perception, the gizmos is not detecting any collision. enter image description here

This doesn't happen when I try using 3d perception in 3d scene instead. I have read enter image description here

And this is my layer and tag for the Cube And this is my layer and tag for the Cube

I expect it to show red spheres showing collision like this in 3d scene. enter image description here

CodePudding user response:

In general: As the name suggests the RayPerceptionSensor2D works for 2D colliders

In Unity the 2D and 3D Physics are two completely separate engines that don't interact in any way!

So either use Collider2D like BoxCollider2D, CirlceCollider2D etc or use a RayPerceptionSensor3D and configure and rotate it accordingly so that it only rays in XY direction.


Besides that you say you have a layer and tag Collectible in your description and the second screenshot shows this, but in your sensor you are searching for Obstacle ... which basically would funnily make this a duplicate of the question you linked ;)


And again in general: Afaik you don't need both, tags and layers. One should be enough, except you really need to go with both systems since you have e.g. multiple different category objects on the same layer you raycast, then you want to filter them using tags.

  • Related