浏览代码

Fix input for dodgeball.

/hh-develop-dodgeball/goy-input
Christopher Goy 4 年前
当前提交
b79970c0
共有 37 个文件被更改,包括 1675 次插入487 次删除
  1. 8
      Project/Assets/InputSystem.inputsettings.asset
  2. 38
      Project/Assets/ML-Agents/Examples/Dodgeball/Input/DodgeBallAgentInput.cs
  3. 67
      Project/Assets/ML-Agents/Examples/Dodgeball/Input/DodgeBallInputActions.cs
  4. 57
      Project/Assets/ML-Agents/Examples/Dodgeball/Input/DodgeBallInputActions.inputactions
  5. 265
      Project/Assets/ML-Agents/Examples/Dodgeball/Prefabs/DodgeballAgent.prefab
  6. 128
      Project/Assets/ML-Agents/Examples/Dodgeball/Prefabs/FPSAgent.prefab
  7. 117
      Project/Assets/ML-Agents/Examples/Dodgeball/Scripts/AgentCubeMovement.cs
  8. 114
      Project/Assets/ML-Agents/Examples/Dodgeball/Scripts/DodgeBallAgent.cs
  9. 15
      Project/Packages/manifest.json
  10. 28
      Project/Packages/packages-lock.json
  11. 1
      Project/Project.sln.DotSettings
  12. 5
      Project/ProjectSettings/EditorBuildSettings.asset
  13. 4
      Project/ProjectSettings/GraphicsSettings.asset
  14. 4
      Project/ProjectSettings/ProjectVersion.txt
  15. 7
      com.unity.ml-agents.extensions/Runtime/Input/Adaptors/ButtonInputActionAdaptor.cs
  16. 7
      com.unity.ml-agents.extensions/Runtime/Input/Adaptors/DoubleInputActionAdaptor.cs
  17. 6
      com.unity.ml-agents.extensions/Runtime/Input/Adaptors/FloatInputActionAdaptor.cs
  18. 6
      com.unity.ml-agents.extensions/Runtime/Input/Adaptors/IntegerInputActionAdaptor.cs
  19. 7
      com.unity.ml-agents.extensions/Runtime/Input/Adaptors/Vector2InputActionAdaptor.cs
  20. 4
      com.unity.ml-agents.extensions/Runtime/Input/IRLActionInputAdaptor.cs
  21. 12
      com.unity.ml-agents.extensions/Runtime/Input/InputActionActuator.cs
  22. 63
      com.unity.ml-agents.extensions/Runtime/Input/InputActuatorComponent.cs
  23. 4
      com.unity.ml-agents.extensions/Runtime/Input/Unity.ML-Agents.Extensions.Input.asmdef
  24. 12
      com.unity.ml-agents.extensions/Tests/Runtime/Input/Adaptors/ButtonInputActionAdaptorTests.cs
  25. 12
      com.unity.ml-agents.extensions/Tests/Runtime/Input/Adaptors/DoubleInputActionAdaptorTests.cs
  26. 12
      com.unity.ml-agents.extensions/Tests/Runtime/Input/Adaptors/FloatInputActionAdapatorTests.cs
  27. 12
      com.unity.ml-agents.extensions/Tests/Runtime/Input/Adaptors/IntegerInputActionAdaptorTests.cs
  28. 12
      com.unity.ml-agents.extensions/Tests/Runtime/Input/Adaptors/Vector2InputActionAdaptorTests.cs
  29. 17
      com.unity.ml-agents.extensions/Tests/Runtime/Input/InputActionActuatorTests.cs
  30. 2
      com.unity.ml-agents.extensions/Tests/Runtime/Input/InputActuatorComponentTests.cs
  31. 2
      com.unity.ml-agents.extensions/Tests/Runtime/Input/Unity.ML-Agents.Extensions.Input.Tests.Runtime.asmdef
  32. 1001
      Project/Assets/ML-Agents/Examples/Dodgeball/Input/DodgeBall.onnx
  33. 14
      Project/Assets/ML-Agents/Examples/Dodgeball/Input/DodgeBall.onnx.meta
  34. 15
      Project/ProjectSettings/BurstAotSettings_StandaloneOSX.json
  35. 81
      com.unity.ml-agents.extensions/Runtime/Input/InputActuatorEventContext.cs
  36. 3
      com.unity.ml-agents.extensions/Runtime/Input/InputActuatorEventContext.cs.meta

8
Project/Assets/InputSystem.inputsettings.asset


m_Script: {fileID: 11500000, guid: c46f07b5ed07e4e92aa78254188d3d10, type: 3}
m_Name: InputSystem.inputsettings
m_EditorClassIdentifier:
m_SupportedDevices: []
m_SupportedDevices:
- Pointer
- Keyboard
- Gamepad
- Mouse
m_UpdateMode: 2
m_CompensateForScreenOrientation: 0
m_FilterNoiseOnCurrent: 0

m_MultiTapDelayTime: 0.75
m_iOSSettings:
m_MotionUsage:
m_Enabled: 0
m_Enabled: 1
m_Description:

38
Project/Assets/ML-Agents/Examples/Dodgeball/Input/DodgeBallAgentInput.cs


using System;
using System.Collections;
using System.Collections.Generic;
using Unity.MLAgents.Extensions.Input;
public class DodgeBallAgentInput : MonoBehaviour
public class DodgeBallAgentInput : MonoBehaviour, IInputActionAssetProvider
private DodgeBallInputActions inputActions;
private DodgeBallInputActions.PlayerActions actionMap;
public DodgeBallInputActions inputActions;
private Gamepad gamepad;
public Vector2 moveInput;

// Start is called before the first frame update
void Awake()
{
inputActions = new DodgeBallInputActions();
actionMap = inputActions.Player;
LazyInitializeInput();
void LazyInitializeInput()
{
if (ReferenceEquals(inputActions, null))
{
inputActions = new DodgeBallInputActions();
}
}
void OnEnable()
{
gamepad = Gamepad.current;

{
return;
}
moveInput = actionMap.Walk.ReadValue<Vector2>();
throwInput = actionMap.Throw.ReadValue<float>();
moveInput = inputActions.Player.Walk.ReadValue<Vector2>();
throwInput = inputActions.Player.Throw.ReadValue<float>();
shieldInput = actionMap.Shield.ReadValue<float>() > 0;
shieldInput = inputActions.Player.Shield.ReadValue<float>() > 0;
rotateInput = actionMap.Rotate.ReadValue<Vector2>();
rotateInput = inputActions.Player.Rotate.ReadValue<Vector2>();
if (actionMap.Throw.triggered)
if (inputActions.Player.Throw.triggered)
if (actionMap.Dash.triggered)
if (inputActions.Player.Dash.triggered)
if (actionMap.Jump.triggered)
if (inputActions.Player.Jump.triggered)
}
public (InputActionAsset, IInputActionCollection2) GetInputActionAsset()
{
LazyInitializeInput();
return (inputActions.asset, inputActions);
}
}

67
Project/Assets/ML-Agents/Examples/Dodgeball/Input/DodgeBallInputActions.cs


""id"": ""cbcb2a57-a474-46a7-b133-cf144f6de321"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """"
""interactions"": ""Press(behavior=2)""
},
{
""name"": ""Shield"",

""type"": ""Button"",
""id"": ""49d5245a-a350-4f94-b4c8-cf578d61000b"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """"
},
{
""name"": ""RotateOld"",
""type"": ""Value"",
""id"": ""b309ca48-95aa-4032-bd7d-46dcaeb138d0"",
""expectedControlType"": ""Axis"",
""processors"": """",
""interactions"": """"
},

},
{
""name"": """",
""id"": ""ac165f0a-fa27-4311-b148-2689537b942b"",
""path"": ""<Pointer>/delta/x"",
""id"": ""4e9015a8-9ef1-4f5b-8776-ed1f246ce741"",
""path"": ""<Mouse>/delta"",
""processors"": """",
""processors"": ""ScaleVector2(x=2,y=2)"",
""action"": ""RotateOld"",
""action"": ""Rotate"",
""name"": ""1D Axis"",
""id"": ""a788bd05-d81e-47f4-a14c-5cb071e21c96"",
""path"": ""1DAxis"",
""name"": """",
""id"": ""0ca23e01-b25e-45e7-a296-dd04d605970a"",
""path"": ""<Gamepad>/leftStick"",
""action"": ""RotateOld"",
""isComposite"": true,
""isPartOfComposite"": false
},
{
""name"": ""negative"",
""id"": ""9844ff0b-6a74-43bb-a969-9f59c74212b9"",
""path"": ""<Gamepad>/rightStick/left"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""RotateOld"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": ""positive"",
""id"": ""b81e038b-8786-4bbe-bb1d-aba1d54112d1"",
""path"": ""<Gamepad>/rightStick/right"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""RotateOld"",
""isComposite"": false,
""isPartOfComposite"": true
},
{
""name"": """",
""id"": ""4e9015a8-9ef1-4f5b-8776-ed1f246ce741"",
""path"": ""<Pointer>/delta"",
""interactions"": """",
""processors"": ""ScaleVector2(x=2,y=2)"",
""groups"": """",
""action"": ""Rotate"",
""isComposite"": false,
""isPartOfComposite"": false

m_Player_Throw = m_Player.FindAction("Throw", throwIfNotFound: true);
m_Player_Shield = m_Player.FindAction("Shield", throwIfNotFound: true);
m_Player_Dash = m_Player.FindAction("Dash", throwIfNotFound: true);
m_Player_RotateOld = m_Player.FindAction("RotateOld", throwIfNotFound: true);
m_Player_Rotate = m_Player.FindAction("Rotate", throwIfNotFound: true);
// UI
m_UI = asset.FindActionMap("UI", throwIfNotFound: true);

private readonly InputAction m_Player_Throw;
private readonly InputAction m_Player_Shield;
private readonly InputAction m_Player_Dash;
private readonly InputAction m_Player_RotateOld;
private readonly InputAction m_Player_Rotate;
public struct PlayerActions
{

public InputAction @Throw => m_Wrapper.m_Player_Throw;
public InputAction @Shield => m_Wrapper.m_Player_Shield;
public InputAction @Dash => m_Wrapper.m_Player_Dash;
public InputAction @RotateOld => m_Wrapper.m_Player_RotateOld;
public InputAction @Rotate => m_Wrapper.m_Player_Rotate;
public InputActionMap Get() { return m_Wrapper.m_Player; }
public void Enable() { Get().Enable(); }

@Dash.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnDash;
@Dash.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnDash;
@Dash.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnDash;
@RotateOld.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnRotateOld;
@RotateOld.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnRotateOld;
@RotateOld.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnRotateOld;
@Rotate.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnRotate;
@Rotate.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnRotate;
@Rotate.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnRotate;

@Dash.started += instance.OnDash;
@Dash.performed += instance.OnDash;
@Dash.canceled += instance.OnDash;
@RotateOld.started += instance.OnRotateOld;
@RotateOld.performed += instance.OnRotateOld;
@RotateOld.canceled += instance.OnRotateOld;
@Rotate.started += instance.OnRotate;
@Rotate.performed += instance.OnRotate;
@Rotate.canceled += instance.OnRotate;

void OnThrow(InputAction.CallbackContext context);
void OnShield(InputAction.CallbackContext context);
void OnDash(InputAction.CallbackContext context);
void OnRotateOld(InputAction.CallbackContext context);
void OnRotate(InputAction.CallbackContext context);
}
public interface IUIActions

57
Project/Assets/ML-Agents/Examples/Dodgeball/Input/DodgeBallInputActions.inputactions


"id": "cbcb2a57-a474-46a7-b133-cf144f6de321",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
"interactions": "Press(behavior=2)"
},
{
"name": "Shield",

"type": "Button",
"id": "49d5245a-a350-4f94-b4c8-cf578d61000b",
"expectedControlType": "Button",
"processors": "",
"interactions": ""
},
{
"name": "RotateOld",
"type": "Value",
"id": "b309ca48-95aa-4032-bd7d-46dcaeb138d0",
"expectedControlType": "Axis",
"processors": "",
"interactions": ""
},

},
{
"name": "",
"id": "ac165f0a-fa27-4311-b148-2689537b942b",
"path": "<Pointer>/delta/x",
"id": "4e9015a8-9ef1-4f5b-8776-ed1f246ce741",
"path": "<Mouse>/delta",
"processors": "",
"processors": "ScaleVector2(x=2,y=2)",
"action": "RotateOld",
"action": "Rotate",
"name": "1D Axis",
"id": "a788bd05-d81e-47f4-a14c-5cb071e21c96",
"path": "1DAxis",
"name": "",
"id": "0ca23e01-b25e-45e7-a296-dd04d605970a",
"path": "<Gamepad>/leftStick",
"groups": "",
"action": "RotateOld",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "negative",
"id": "9844ff0b-6a74-43bb-a969-9f59c74212b9",
"path": "<Gamepad>/rightStick/left",
"interactions": "",
"processors": "",
"groups": "",
"action": "RotateOld",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "positive",
"id": "b81e038b-8786-4bbe-bb1d-aba1d54112d1",
"path": "<Gamepad>/rightStick/right",
"interactions": "",
"processors": "",
"groups": "",
"action": "RotateOld",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "",
"id": "4e9015a8-9ef1-4f5b-8776-ed1f246ce741",
"path": "<Pointer>/delta",
"interactions": "",
"processors": "ScaleVector2(x=2,y=2)",
"groups": "",
"action": "Rotate",
"isComposite": false,

265
Project/Assets/ML-Agents/Examples/Dodgeball/Prefabs/DodgeballAgent.prefab


- component: {fileID: 6960991000376283099}
- component: {fileID: 6960991000376283103}
- component: {fileID: 886896010}
- component: {fileID: 7866554473793389977}
- component: {fileID: 1187197036662478906}
m_Layer: 11
m_Name: DodgeballAgent
m_TagString: blueAgent

VectorObservationSize: 5
NumStackedVectorObservations: 1
m_ActionSpec:
m_NumContinuousActions: 5
m_NumContinuousActions: 0
VectorActionSize: 05000000
VectorActionSize:
VectorActionSpaceType: 1
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 0}
m_InferenceDevice: 0

shieldInput: 0
Cam: {fileID: 0}
throwPressed: 0
--- !u!114 &7866554473793389977
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6960991000376283098}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Actions: {fileID: -944628639613478452, guid: 77b3cef930f53497fa86a02fe6c7f145,
type: 3}
m_NotificationBehavior: 3
m_UIInputModule: {fileID: 0}
m_DeviceLostEvent:
m_PersistentCalls:
m_Calls: []
m_DeviceRegainedEvent:
m_PersistentCalls:
m_Calls: []
m_ControlsChangedEvent:
m_PersistentCalls:
m_Calls: []
m_ActionEvents: []
m_NeverAutoSwitchControlSchemes: 0
m_DefaultControlScheme:
m_DefaultActionMap: Player
m_SplitScreenIndex: -1
m_Camera: {fileID: 0}
--- !u!114 &1187197036662478906
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6960991000376283098}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33005b124d7f841a191249baf2bacb2a, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ActionSpec:
m_NumContinuousActions: 5
BranchSizes: 02000000020000000200000002000000
--- !u!1 &6960991000723819014
GameObject:
m_ObjectHideFlags: 0

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}

m_Modifications:
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_LocalScale.x
value: 92.80849
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_LocalScale.y
value: 92.808495
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_LocalScale.z
value: 92.808495
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_LocalPosition.x
value: 0.314
objectReference: {fileID: 0}

objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_LocalRotation.w
value: -0.24542792
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_LocalRotation.x
value: -0.2857865
objectReference: {fileID: 0}

objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_LocalRotation.w
value: -0.24542792
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: -45.667004
objectReference: {fileID: 0}

propertyPath: m_LocalEulerAnglesHint.z
value: 97.162
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_LocalScale.x
value: 92.80849
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_LocalScale.y
value: 92.808495
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_LocalScale.z
value: 92.808495
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: e1cfe4a07c0f04f47937a409188b53d2,
type: 3}
propertyPath: m_Name

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}

- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalScale.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalScale.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalScale.z
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalPosition.x
value: 0.75
objectReference: {fileID: 0}

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.9999144
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.9999144
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalScale.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalScale.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalScale.z
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8494615155775840143, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_Materials.Array.data[0]

m_Modifications:
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_RootOrder
value: 6
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_LocalScale.x
value: 2.508
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_LocalScale.y
value: 2.508
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_LocalScale.z
value: 2.508
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}

type: 3}
propertyPath: m_LocalPosition.z
value: 0.2
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_LocalRotation.w
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}

objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_LocalRotation.w
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_RootOrder
value: 6
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: -89.98
objectReference: {fileID: 0}

propertyPath: m_LocalEulerAnglesHint.z
value: 180
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_LocalScale.x
value: 2.508
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_LocalScale.y
value: 2.508
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_LocalScale.z
value: 2.508
objectReference: {fileID: 0}
- target: {fileID: -7511558181221131132, guid: 7615e51ff67b746f0821b55c04f2b490,
type: 3}
propertyPath: m_Materials.Array.data[0]

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
propertyPath: m_LocalRotation.w
value: 1
propertyPath: m_LocalRotation.y
propertyPath: m_LocalRotation.x
propertyPath: m_LocalRotation.z
propertyPath: m_LocalRotation.y
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,

128
Project/Assets/ML-Agents/Examples/Dodgeball/Prefabs/FPSAgent.prefab


m_Name:
m_EditorClassIdentifier:
AllowKeyboardInput: 0
initialized: 0
shootKey: 106
autoShootEnabled: 0
shootingRate: 0

numberOfProjectilesToPool: 35
projectileOrigin: {fileID: 2747490485103127816}
projectilePoolList: []
forceMode: 2
UseMuzzleFlash: 0
forceMode: 2
GunSFX: {fileID: 0}
UseScreenShake: 1
ShakeTransform: 1

m_Name:
m_EditorClassIdentifier:
AllowKeyboardInput: 0
initialized: 0
shootKey: 106
autoShootEnabled: 0
shootingRate: 0

numberOfProjectilesToPool: 35
projectileOrigin: {fileID: 2747490484821474612}
projectilePoolList: []
forceMode: 2
UseMuzzleFlash: 0
forceMode: 2
GunSFX: {fileID: 0}
UseScreenShake: 1
ShakeTransform: 1

m_BrainParameters:
VectorObservationSize: 0
NumStackedVectorObservations: 1
VectorActionSize: 07000000
m_ActionSpec:
m_NumContinuousActions: 0
BranchSizes:
VectorActionSize:
VectorActionSpaceType: 1
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 0}
m_InferenceDevice: 0
m_BehaviorType: 0

m_Script: {fileID: 11500000, guid: 0b86732e5cf714ed6ba8b18dd80f458c, type: 3}
m_Name:
m_EditorClassIdentifier:
allowKeyboardInput: 0
allowHumanInput: 1
maxAngularVel: 50
runningForceMode: 2
agentRunSpeed: 10

groundPoundForceMode: 1
groundPoundForce: 35
spinAttackSpeed: 20
UseMouseRotation: 1
axes: 0
sensitivityX: 15
sensitivityY: 15
minimumX: -360
maximumX: 360
minimumY: -60
maximumY: 60
MatchCameraRotation: 0
invertRotationIfWalkingBackwards: 0
agentRotationSpeed: 250
canJump: 1

shootInput: 0
jumpInput: 0
dashInput: 0
rotateInput: 0
rotateInput: {x: 0, y: 0}
shootPressed: 0
--- !u!114 &7796409947774005661
MonoBehaviour:
m_ObjectHideFlags: 0

m_Calls: []
m_ActionId: e94117bb-34b9-400e-98a4-5bcdc0e1ef18
m_ActionName: UI/Restart[/Keyboard/r,/XboxOneGampadMacOSWireless/buttonNorth]
- m_PersistentCalls:
m_Calls: []
m_ActionId: 7172bb7c-a5ae-46b9-af48-2f521eb69773
m_ActionName: Player/Rotate[/Mouse/delta]
m_NeverAutoSwitchControlSchemes: 0
m_DefaultControlScheme:
m_DefaultActionMap: Player

ModeOverride: 0
LensShift: {x: 0, y: 0}
GateFit: 0
m_SensorSize: {x: 1.6, y: 1}
m_SensorSize: {x: 1.5259843, y: 1}
m_Transitions:
m_BlendHint: 0
m_InheritPosition: 0

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
propertyPath: m_LocalRotation.w
value: 1
propertyPath: m_LocalRotation.y
propertyPath: m_LocalRotation.x
propertyPath: m_LocalRotation.z
propertyPath: m_LocalRotation.y
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalScale.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalScale.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalScale.z
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalPosition.x
value: 0.75
objectReference: {fileID: 0}

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.9999144
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.9999144
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalScale.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalScale.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalScale.z
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8494615155775840143, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_Materials.Array.data[0]

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}

objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
propertyPath: m_LocalRotation.w
value: 1
propertyPath: m_LocalRotation.y
propertyPath: m_LocalRotation.x
propertyPath: m_LocalRotation.z
propertyPath: m_LocalRotation.y
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,
type: 3}
propertyPath: m_RootOrder
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6284117573631589716, guid: 1b24fe96fd75b4646a6e7bf65b6a4943,

117
Project/Assets/ML-Agents/Examples/Dodgeball/Scripts/AgentCubeMovement.cs


using System;
using Unity.Mathematics;
using Unity.MLAgents.Policies;
using UnityEngine.InputSystem;
namespace MLAgents
{

public float spinAttackSpeed = 20f;
private bool spinAttack;
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 };
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 };
[Header("BODY ROTATION")] public bool UseMouseRotation = true;
public RotationAxes axes = RotationAxes.MouseXAndY;

{
rb = GetComponent<Rigidbody>();
groundCheck = GetComponent<AgentCubeGroundCheck>();
// Share the input asset instance between objects.
m_DodgeballInput = GetComponent<DodgeBallAgentInput>();
m_DodgeballInput.inputActions.Player.Jump.performed += JumpOnPerformed;
m_DodgeballInput.inputActions.Player.Dash.performed += DashOnPerformed;
m_Bp = GetComponent<BehaviorParameters>();
void Update()
void OnDisable()
if (!allowHumanInput)
m_DodgeballInput.inputActions.Player.Jump.performed -= JumpOnPerformed;
m_DodgeballInput.inputActions.Player.Dash.performed -= DashOnPerformed;
}
void DashOnPerformed(InputAction.CallbackContext obj)
{
if (m_DodgeballInput.Cam != null)
return;
Dash(m_DodgeballInput.Cam.transform.TransformDirection(new Vector3(inputH, 0, inputV)));
}
else if (allowHumanInput)
{
Dash(transform.forward);
//FORWARD MOVEMENT
inputV = Input.GetAxisRaw("Vertical");
inputH = Input.GetAxisRaw("Horizontal");
spinAttack = Input.GetKey(KeyCode.H);
dashPressed = Input.GetKeyDown(KeyCode.K);
jump = Input.GetKeyDown(KeyCode.Space);
var camForward = cam.transform.forward;
camForward.y = 0;
var camRight = cam.transform.right;
}
if (canJump && Input.GetKeyDown(KeyCode.Space))
void JumpOnPerformed(InputAction.CallbackContext obj)
{
if (groundCheck.isGrounded)
if (groundCheck)
{
if (groundCheck.isGrounded)
{
Jump();
}
else if (UseGroundPound)
{
rb.AddForce(Vector3.down * groundPoundForce, groundPoundForceMode);
}
}
Jump();
if (dashPressed)
else if (UseGroundPound)
// dashPressed = false;
// rb.AddForce(rb.transform.forward * dashBoostForce, dashForceMode);
rb.AddTorque(rb.transform.right * dashBoostForce, dashForceMode);
print("dashPressed");
rb.AddForce(Vector3.down * groundPoundForce, groundPoundForceMode);
public void RotateBody(float rotateAxis, float forwardAxis)
{

public void Look(float xRot = 0, float yRot = 0)
{
// Read the mouse input axis
rotationX += xRot * sensitivityX;
rotationY += yRot * sensitivityY;
// rotationX += xRot * sensitivityX * Time.deltaTime;
// rotationY += yRot * sensitivityY * Time.deltaTime;
// rotationX += Input.GetAxis("Mouse X") * sensitivityX;
// rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationX = ClampAngle(rotationX, minimumX, maximumX);
rotationY = ClampAngle(rotationY, minimumY, maximumY);
Quaternion xQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up);
Quaternion yQuaternion = Quaternion.AngleAxis(rotationY, -Vector3.right);
// Read the mouse input axis
rotationX += xRot * sensitivityX;
rotationY += yRot * sensitivityY;
// rotationX += xRot * sensitivityX * Time.deltaTime;
// rotationY += yRot * sensitivityY * Time.deltaTime;
// rotationX += Input.GetAxis("Mouse X") * sensitivityX;
// rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationX = ClampAngle(rotationX, minimumX, maximumX);
rotationY = ClampAngle(rotationY, minimumY, maximumY);
Quaternion xQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up);
Quaternion yQuaternion = Quaternion.AngleAxis(rotationY, -Vector3.right);
transform.localRotation = originalRotation * xQuaternion * yQuaternion;
// print("look");
transform.localRotation = originalRotation * xQuaternion * yQuaternion;
// print("look");
}
public bool applyStandingForce = false;

DodgeBallAgentInput m_DodgeballInput;
BehaviorParameters m_Bp;
void FixedUpdate()
{
strafeCoolDownTimer += Time.fixedDeltaTime;

// print("AddFallingForce");
}
var rotate = m_DodgeballInput.rotateInput;
inputH = m_DodgeballInput.moveInput.x;
inputV = m_DodgeballInput.moveInput.y;
var movDir = transform.TransformDirection(new Vector3(inputH, 0, inputV));
RunOnGround(movDir);
Look(rotate.x, rotate.y);
if (UseMouseRotation)
{
if (axes == RotationAxes.MouseXAndY)

var moveDir = transform.TransformDirection(new Vector3(inputH, 0, inputV));
if (groundCheck.isGrounded)
{
RunOnGround(moveDir);
}
// else
// {
// RunInAir(dir.normalized);
// }
if (groundCheck.isGrounded)
{
RunOnGround(moveDir);
}
// else
// {
// RunInAir(dir.normalized);
// }
if (inputH == 0 && inputV == 0)
{

114
Project/Assets/ML-Agents/Examples/Dodgeball/Scripts/DodgeBallAgent.cs


m_StartingPos = transform.position;
m_StartingRot = transform.rotation;
m_Initialized = true;
input.inputActions.Player.Throw.canceled += ThrowOnperformed;
}
protected override void OnDisable()
{
base.OnDisable();
input.inputActions.Player.Throw.canceled -= ThrowOnperformed;
}
void ThrowOnperformed(InputAction.CallbackContext obj)
{
// TODO Throw when the button is released?
if (obj.action.WasReleasedThisFrame())
{
ThrowTheBall();
}
}
public override void OnEpisodeBegin()

{
// sensor.AddObservation((float)StepCount / (float)MaxStep); //Helps with credit assign?
sensor.AddObservation(ThrowController.coolDownWait); //Held DBs Normalized
sensor.AddObservation((float)currentNumberOfBalls/4); //Held DBs Normalized
sensor.AddObservation((float)HitPointsRemaining/(float)NumberOfTimesPlayerCanBeHit); //Remaining Hit Points Normalized
sensor.AddObservation((float)currentNumberOfBalls / 4); //Held DBs Normalized
sensor.AddObservation((float)HitPointsRemaining / (float)NumberOfTimesPlayerCanBeHit); //Remaining Hit Points Normalized
// // sensor.AddObservation(localVelocity.x);
// // sensor.AddObservation(localVelocity.z);
// // sensor.AddObservation(m_Frozen);
// // sensor.AddObservation(m_ShootInput);
// // sensor.AddObservation(localVelocity.x);
// // sensor.AddObservation(localVelocity.z);
// // sensor.AddObservation(m_Frozen);
// // sensor.AddObservation(m_ShootInput);
}
// else if (useVectorFrozenFlag)
// {

// public void MoveAgent(ActionSegment<float> act)
public void MoveAgent(ActionBuffers actionBuffers)
{
// if (DoNotPerformActions)
// {
// return;
// }
var continuousActions = actionBuffers.ContinuousActions;
var discreteActions = actionBuffers.DiscreteActions;
m_InputV = continuousActions[0];
m_InputH = continuousActions[1];
m_Rotate = continuousActions[2];
m_ThrowInput = (int)discreteActions[0];;
m_DashInput = (int)discreteActions[1];;
//HANDLE ROTATION
m_CubeMovement.Look(m_Rotate);
//HANDLE XZ MOVEMENT
var moveDir = transform.TransformDirection(new Vector3(m_InputH, 0, m_InputV));
m_CubeMovement.RunOnGround(moveDir);
// if (AgentShield && act[6] > 0)
// {
// AgentShield.ActivateShield(true);
// }
// else
// {
// AgentShield.ActivateShield(false);
// }
//HANDLE THROWING
if (m_ThrowInput > 0)
// if (input.shootPressed)
{
ThrowTheBall();
}
//HANDLE DASH MOVEMENT
if (m_DashInput > 0)
{
m_CubeMovement.Dash(moveDir);
}
}
public void ThrowTheBall()
{
if (currentNumberOfBalls > 0 && !ThrowController.coolDownWait)

}
}
public override void OnActionReceived(ActionBuffers actionBuffers)
{
// print("MoveAgent");
MoveAgent(actionBuffers);
}
IEnumerator ShowHitFace()
{
WaitForFixedUpdate wait = new WaitForFixedUpdate();

public void PlayHitFX()
{
ThrowController.impulseSource.GenerateImpulse();
// HitSoundAudioSource.Play();
HitSoundAudioSource.PlayOneShot(BallImpactAudioClip, 1f);
HitSoundAudioSource.PlayOneShot(HurtVoiceAudioClip, 1f);
HitByParticles.Play();
if (AnimateEyes)
{
StartCoroutine(ShowHitFace());
}
ThrowController.impulseSource.GenerateImpulse();
// HitSoundAudioSource.Play();
HitSoundAudioSource.PlayOneShot(BallImpactAudioClip, 1f);
HitSoundAudioSource.PlayOneShot(HurtVoiceAudioClip, 1f);
HitByParticles.Play();
if (AnimateEyes)
{
StartCoroutine(ShowHitFace());
}
}
private void OnCollisionEnter(Collision col)

db.BallIsInPlay(true);
db.gameObject.SetActive(false);
// ActiveBallsList.Add(db);
}
public override void Heuristic(in ActionBuffers actionsOut)
{
var contActionsOut = actionsOut.ContinuousActions;
contActionsOut[0] = input.moveInput.y;
contActionsOut[1] = input.moveInput.x;
contActionsOut[2] = input.rotateInput.x; //rotate
// contActionsOut[3] = input.throwPressed ? 1 : 0; //shoot
var discreteActionsOut = actionsOut.DiscreteActions;
discreteActionsOut[0] = input.CheckIfInputSinceLastFrame(ref input.throwPressed) ? 1 : 0; //dash
// contActionsOut[3] = input.throwInput; //shoot
discreteActionsOut[1] = input.CheckIfInputSinceLastFrame(ref input.dashInput) ? 1 : 0; //dash
}
}

15
Project/Packages/manifest.json


"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.ads": "3.5.0",
"com.unity.ads": "3.6.1",
"com.unity.analytics": "3.3.5",
"com.unity.cinemachine": "2.7.1",
"com.unity.collab-proxy": "1.2.16",

"com.unity.ml-agents": "file:../../com.unity.ml-agents",
"com.unity.ml-agents.extensions": "file:../../com.unity.ml-agents.extensions",
"com.unity.multiplayer-hlapi": "1.0.6",
"com.unity.multiplayer-hlapi": "1.0.8",
"com.unity.purchasing": "2.1.1",
"com.unity.test-framework": "1.1.18",
"com.unity.purchasing": "2.2.2",
"com.unity.test-framework": "1.1.22",
"com.unity.timeline": "1.2.6",
"com.unity.timeline": "1.2.18",
"com.unity.xr.legacyinputhelpers": "2.1.4",
"com.unity.xr.legacyinputhelpers": "2.1.7",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",

},
"testables": [
"com.unity.ml-agents",
"com.unity.ml-agents.extensions"
"com.unity.ml-agents.extensions",
"com.unity.inputsystem"
]
}

28
Project/Packages/packages-lock.json


"dependencies": {}
},
"com.unity.ads": {
"version": "3.5.0",
"version": "3.6.1",
"depth": 0,
"source": "registry",
"dependencies": {

"url": "https://packages.unity.com"
},
"com.unity.ext.nunit": {
"version": "1.0.0",
"version": "1.0.6",
"depth": 1,
"source": "registry",
"dependencies": {},

}
},
"com.unity.multiplayer-hlapi": {
"version": "1.0.6",
"version": "1.0.8",
"depth": 0,
"source": "registry",
"dependencies": {

"url": "https://packages.unity.com"
},
"com.unity.purchasing": {
"version": "2.1.1",
"version": "2.2.2",
"depth": 0,
"source": "registry",
"dependencies": {

},
"com.unity.test-framework": {
"version": "1.1.18",
"version": "1.1.22",
"com.unity.ext.nunit": "1.0.0",
"com.unity.ext.nunit": "1.0.6",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
},

"url": "https://packages.unity.com"
},
"com.unity.timeline": {
"version": "1.2.6",
"version": "1.2.18",
"dependencies": {},
"dependencies": {
"com.unity.modules.director": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.ugui": {

}
},
"com.unity.xr.legacyinputhelpers": {
"version": "2.1.4",
"version": "2.1.7",
"dependencies": {},
"dependencies": {
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.xr": "1.0.0"
},
"url": "https://packages.unity.com"
},
"nuget.mono-cecil": {

1
Project/Project.sln.DotSettings


<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RL/@EntryIndexedValue">RL</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dont/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

5
Project/ProjectSettings/EditorBuildSettings.asset


EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes: []
m_Scenes:
- enabled: 1
path: Assets/ML-Agents/Examples/Dodgeball/Scenes/Dodgeball.unity
guid: bb9eaf2690d8442a396456665bfe11d6
m_configObjects:
com.unity.input.settings: {fileID: 11400000, guid: 4d91049841035460f9654c1b5e05c046,
type: 2}

4
Project/ProjectSettings/GraphicsSettings.asset


--- !u!30 &1
GraphicsSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
serializedVersion: 13
m_Deferred:
m_Mode: 1
m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}

- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}

m_LightsUseLinearIntensity: 0
m_LightsUseColorTemperature: 0
m_LogWhenShaderIsCompiled: 0
m_AllowEnlightenSupportForUpgradedProject: 1

4
Project/ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2019.4.15f1
m_EditorVersionWithRevision: 2019.4.15f1 (fbf367ac14e9)
m_EditorVersion: 2019.4.19f1
m_EditorVersionWithRevision: 2019.4.19f1 (ca5b14067cec)

7
com.unity.ml-agents.extensions/Runtime/Input/Adaptors/ButtonInputActionAdaptor.cs


using Unity.MLAgents.Actuators;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.LowLevel;
namespace Unity.MLAgents.Extensions.Input

}
/// TODO again this might need to be more nuanced for things like continuous buttons.
/// <inheritdoc cref="IRLActionInputAdaptor.QueueInputEventForAction"/>
public void QueueInputEventForAction(InputAction action, InputControl control, ActionSpec actionSpec, in ActionBuffers actionBuffers)
/// <inheritdoc cref="IRLActionInputAdaptor.WriteToInputEventForAction"/>
public void WriteToInputEventForAction(InputEventPtr eventPtr, InputAction action, InputControl control, ActionSpec actionSpec, in ActionBuffers actionBuffers)
InputSystem.QueueDeltaStateEvent(control, (byte)val);
((ButtonControl)control).WriteValueIntoEvent((float)val, eventPtr);
}
/// <inheritdoc cref="IRLActionInputAdaptor.WriteToHeuristic"/>>

7
com.unity.ml-agents.extensions/Runtime/Input/Adaptors/DoubleInputActionAdaptor.cs


#if MLA_INPUT_SYSTEM && UNITY_2019_4_OR_NEWER
using Unity.MLAgents.Actuators;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.LowLevel;
namespace Unity.MLAgents.Extensions.Input

return ActionSpec.MakeContinuous(1);
}
/// <inheritdoc cref="IRLActionInputAdaptor.QueueInputEventForAction"/>
public void QueueInputEventForAction(InputAction action, InputControl control, ActionSpec actionSpec, in ActionBuffers actionBuffers)
/// <inheritdoc cref="IRLActionInputAdaptor.WriteToInputEventForAction"/>
public void WriteToInputEventForAction(InputEventPtr eventPtr, InputAction action, InputControl control, ActionSpec actionSpec, in ActionBuffers actionBuffers)
InputSystem.QueueDeltaStateEvent(control,(double)val);
((DoubleControl)control).WriteValueIntoEvent((double)val, eventPtr);
}
/// <inheritdoc cref="IRLActionInputAdaptor.WriteToHeuristic"/>

6
com.unity.ml-agents.extensions/Runtime/Input/Adaptors/FloatInputActionAdaptor.cs


return ActionSpec.MakeContinuous(1);
}
/// <inheritdoc cref="IRLActionInputAdaptor.QueueInputEventForAction"/>
public void QueueInputEventForAction(InputAction action, InputControl control, ActionSpec actionSpec, in ActionBuffers actionBuffers)
/// <inheritdoc cref="IRLActionInputAdaptor.WriteToInputEventForAction"/>
public void WriteToInputEventForAction(InputEventPtr eventPtr, InputAction action, InputControl control, ActionSpec actionSpec, in ActionBuffers actionBuffers)
InputSystem.QueueDeltaStateEvent(control, val);
control.WriteValueIntoEvent(val, eventPtr);
}
/// <inheritdoc cref="IRLActionInputAdaptor.WriteToHeuristic"/>

6
com.unity.ml-agents.extensions/Runtime/Input/Adaptors/IntegerInputActionAdaptor.cs


return ActionSpec.MakeDiscrete(2);
}
/// <inheritdoc cref="IRLActionInputAdaptor.QueueInputEventForAction"/>
public void QueueInputEventForAction(InputAction action, InputControl control, ActionSpec actionSpec, in ActionBuffers actionBuffers)
/// <inheritdoc cref="IRLActionInputAdaptor.WriteToInputEventForAction"/>
public void WriteToInputEventForAction(InputEventPtr eventPtr, InputAction action, InputControl control, ActionSpec actionSpec, in ActionBuffers actionBuffers)
InputSystem.QueueDeltaStateEvent(control, val);