Unity-Technologies / ml-agents

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
https://unity.com/products/machine-learning-agents
Other
16.93k stars 4.14k forks source link

Detactable Tags in Ray Perception Sensor3D are not working #4178

Closed Hsgngr closed 4 years ago

Hsgngr commented 4 years ago

Describe the bug I would like to use Raycast for deteching one thing however it collides with every collider in the scene.

To Reproduce Steps to reproduce the behavior: 1.Clone https://github.com/Hsgngr/Pandemic_Simulation.git

  1. Open the project with Unity Path: Pandemic_Simulation\ml-agents-release_3\ml-agents-release_3\Project
  2. Click on 'Assets/PandemicSimulation/Scenes/T1'
  3. Inpect PandemicArea>PandemicAgent.RayPerception Sensor 3D
  4. See the error.

Screenshots The agent's ray perception sensor (blue one) hits another cubes sphere collider which I only want to use for triggering certain actions. I dont want to detect that. There is another collider which I would like to reach.

image

My agent has 2 colliders. SphereCollider is for triggering some actions and the other one is a cube collider which is attacthed to a child of this agent. This child object has ColliderCube tag and in my Detectable Tags: I am only giving wall and ColliderCube

image

Desired Behaviour

image It hits directly to the box collider (I deactivate other sphere collider)

Environment (please complete the following information):

Hsgngr commented 4 years ago

I solved the problem by using Layers. I added a new layer for the agent prefab and only added this to the parent object. I took the cube collider and put that as a child. Then I changed only parent's layer. I closed IgnoreRaycast from Project Settings/Physics (InfectionLayer is the agent layer)

image

I unchecked the Ray Layer Mask > InfectiousLayer in RayPerceptionSensor3D

image

and voila. Now it hit as it should.

image

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.