简体   繁体   中英

Ray Perception Sensor 2D gizmos not detecting collision

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.在此处输入图像描述

This doesn't happen when I try using 3d perception in 3d scene instead. I have read this question , and have tried doing the same but it's still not showing any red lines representing a collision.

Currently I have added a new Collectible layer and tag, and assign it to the Cubes, with Untagged tag and Default layer for the Sphere object.

Here's my settings for the Sphere object's Ray Perception这是我对 Sphere 对象的 Ray Perception 的设置

edit: image above is wrong (as mentioned in the ans), I have tried this but still doesn't work在此处输入图像描述

And this is my layer and tag for the Cube这是我的多维数据集图层和标签

I expect it to show red spheres showing collision like this in 3d scene.在此处输入图像描述

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 eg multiple different category objects on the same layer you raycast, then you want to filter them using tags.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM