-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn if no joints on Root Body #5387
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirmed null ref error is gone. looks good.
|
||
internal bool IsTrivial() | ||
{ | ||
var joints = RootBody.GetComponentsInChildren<Joint>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either need to null check RootBody, or if it's null maybe we just transform.GetComponentsInChildren<Joint>();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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