Warn if no joints on Root Body#5387
Conversation
Hunter-Unity
left a comment
There was a problem hiding this comment.
i opened walker and added a RigidBodySensorComponent the WalkerRagdoll gameobject and it generates null refs when a RootBody isn't specified
NullReferenceException: Object reference not set to an instance of an object Unity.MLAgents.Extensions.Sensors.RigidBodySensorComponent.IsTrivial () (at /Users/brandonh/unity_projects/ml-agents-master/ml-agents/com.unity.ml-agents.extensions/Runtime/Sensors/RigidBodySensorComponent.cs:97) Unity.MLAgents.Extensions.Editor.RigidBodySensorComponentEditor.OnInspectorGUI () (at /Users/brandonh/unity_projects/ml-agents-master/ml-agents/com.unity.ml-agents.extensions/Editor/RigidBodySensorComponentEditor.cs:19) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at /Users/bokken/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:527) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:197)
Hunter-Unity
left a comment
There was a problem hiding this comment.
confirmed null ref error is gone. looks good.
|
|
||
| internal bool IsTrivial() | ||
| { | ||
| var joints = RootBody.GetComponentsInChildren<Joint>(); |
There was a problem hiding this comment.
either need to null check RootBody, or if it's null maybe we just transform.GetComponentsInChildren<Joint>();
There was a problem hiding this comment.
Added the null-check above, so RootBody will always be non-null here.
Proposed change(s)
If there are no joints on a Rigid Body, the Rigid Body Sensor won't generate any useful observations, just identity values (unless there's a Virtual Root set, and that's different from the RB's GameObject). This adds a warning to the inspector in that case.
Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)
Types of change(s)
Checklist