From 5e024fe617b2cdb895deaa939cdadc6d90f36cdf Mon Sep 17 00:00:00 2001 From: Cailean Finn Date: Tue, 26 Mar 2024 12:45:01 +0000 Subject: [PATCH] added sitting toggle & fixed kitchen worktop colliders --- Assets/6_Scenes/Beep.unity | 53 ++++++++++++++++++-- Assets/7_Scripts/Agent/Walker.cs | 39 ++++++++++---- Assets/7_Scripts/Waypoint/WaypointManager.cs | 2 +- Assets/ML-Agents/Timers/Beep_timers.json | 2 +- 4 files changed, 80 insertions(+), 16 deletions(-) diff --git a/Assets/6_Scenes/Beep.unity b/Assets/6_Scenes/Beep.unity index 71ebacc..edca6fd 100644 --- a/Assets/6_Scenes/Beep.unity +++ b/Assets/6_Scenes/Beep.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 14693.596, g: 17306.041, b: 19108.33, a: 1} + m_IndirectSpecularColor: {r: 14693.611, g: 17306.041, b: 19108.33, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -1069,7 +1069,7 @@ MonoBehaviour: LensShift: {x: 0, y: 0} GateFit: 1 FocusDistance: 8.93528 - m_SensorSize: {x: 1, y: 1} + m_SensorSize: {x: 70.41, y: 52.63} Iso: 50 ShutterSpeed: 0.0005 Aperture: 2.2 @@ -1150,7 +1150,7 @@ MonoBehaviour: LensShift: {x: 0, y: 0} GateFit: 1 FocusDistance: 0.01 - m_SensorSize: {x: 1, y: 1} + m_SensorSize: {x: 70.41, y: 52.63} Iso: 50 ShutterSpeed: 0.0005 Aperture: 1.9 @@ -1738,7 +1738,7 @@ MonoBehaviour: LensShift: {x: 0, y: 0} GateFit: 1 FocusDistance: 8.93528 - m_SensorSize: {x: 1, y: 1} + m_SensorSize: {x: 70.41, y: 52.63} Iso: 50 ShutterSpeed: 0.0005 Aperture: 2.2 @@ -5536,6 +5536,31 @@ PrefabInstance: value: objectReference: {fileID: 13400000, guid: 2dcff4a562f7e4820bd8128d56dc94e5, type: 2} + - target: {fileID: 1141904950044442108, guid: 14d8283abcefffd4a916b8611ccd49fa, + type: 3} + propertyPath: m_Size.y + value: 47.05041 + objectReference: {fileID: 0} + - target: {fileID: 1141904950044442108, guid: 14d8283abcefffd4a916b8611ccd49fa, + type: 3} + propertyPath: m_Size.z + value: 221.29889 + objectReference: {fileID: 0} + - target: {fileID: 1141904950044442108, guid: 14d8283abcefffd4a916b8611ccd49fa, + type: 3} + propertyPath: m_Center.x + value: -15.609625 + objectReference: {fileID: 0} + - target: {fileID: 1141904950044442108, guid: 14d8283abcefffd4a916b8611ccd49fa, + type: 3} + propertyPath: m_Center.y + value: 7.674981 + objectReference: {fileID: 0} + - target: {fileID: 1141904950044442108, guid: 14d8283abcefffd4a916b8611ccd49fa, + type: 3} + propertyPath: m_Center.z + value: 15.15628 + objectReference: {fileID: 0} - target: {fileID: 1640394629942947327, guid: 14d8283abcefffd4a916b8611ccd49fa, type: 3} propertyPath: m_Material @@ -5643,6 +5668,26 @@ PrefabInstance: propertyPath: m_TagString value: sit objectReference: {fileID: 0} + - target: {fileID: 5174530303335247217, guid: 14d8283abcefffd4a916b8611ccd49fa, + type: 3} + propertyPath: m_Size.y + value: 47.10635 + objectReference: {fileID: 0} + - target: {fileID: 5174530303335247217, guid: 14d8283abcefffd4a916b8611ccd49fa, + type: 3} + propertyPath: m_Size.z + value: 30.965382 + objectReference: {fileID: 0} + - target: {fileID: 5174530303335247217, guid: 14d8283abcefffd4a916b8611ccd49fa, + type: 3} + propertyPath: m_Center.x + value: 32.7901 + objectReference: {fileID: 0} + - target: {fileID: 5174530303335247217, guid: 14d8283abcefffd4a916b8611ccd49fa, + type: 3} + propertyPath: m_Center.y + value: 7.6469703 + objectReference: {fileID: 0} - target: {fileID: 5588445531737750407, guid: 14d8283abcefffd4a916b8611ccd49fa, type: 3} propertyPath: m_Material diff --git a/Assets/7_Scripts/Agent/Walker.cs b/Assets/7_Scripts/Agent/Walker.cs index 5b42a53..e819f89 100644 --- a/Assets/7_Scripts/Agent/Walker.cs +++ b/Assets/7_Scripts/Agent/Walker.cs @@ -61,7 +61,8 @@ public class Walker : Agent private Terrain m_Terrain; [HideInInspector] - public bool m_FinishedSwap = false; + public bool m_FinishedSwapGetup = false; + public bool m_FinishedSwapSit = false; [HideInInspector] public ModelSwap m_ModelSwapper; @@ -144,7 +145,6 @@ public class Walker : Agent */ public override void OnEpisodeBegin() { - Debug.Log("Begin!"); // Set values of Joint Controller for exploring emrgent behvaiours if (m_SelectedBrain == Brain.DMScrambler) { @@ -386,24 +386,43 @@ public class Walker : Agent } + // Switch the model given the current input from the user + // G -> Getup + // S -> Sit + // This is a simple toggle private void InputSwitchModel() { - if (Input.GetKeyDown(KeyCode.G)) + if (Input.GetKeyDown(KeyCode.G) && !m_ModelSwapper.m_currentModelName.Equals("Sitting")) { - if( !m_FinishedSwap ) + if( !m_FinishedSwapGetup) { - m_FinishedSwap = true; + m_FinishedSwapGetup = true; m_ModelSwapper.m_PastModel = m_ModelSwapper.m_currentModelName; m_ModelSwapper.SwitchModel("Getup", this); } else { - m_FinishedSwap = false; + m_FinishedSwapGetup = false; m_ModelSwapper.SwitchModel(m_ModelSwapper.m_PastModel, this); } } + if ( Input.GetKeyDown(KeyCode.S) && !m_ModelSwapper.m_currentModelName.Equals("Getup")) + { + if (!m_FinishedSwapSit) + { + m_FinishedSwapSit = true; + m_ModelSwapper.m_PastModel = m_ModelSwapper.m_currentModelName; + m_ModelSwapper.SwitchModel("Sitting", this); + } + else + { + m_FinishedSwapSit = false; + m_ModelSwapper.SwitchModel(m_ModelSwapper.m_PastModel, this); + } + } + } private void SwitchModelAfterFalling() @@ -413,17 +432,17 @@ public class Walker : Agent // If on, check its rotation, and if certain parts are touching the floor Vector2 deltaAngle = GetAngleDeltaXZ(); - if ((deltaAngle.y < 0.3 || deltaAngle.x < 0.3) && !m_FinishedSwap) + if ((deltaAngle.y < 0.3 || deltaAngle.x < 0.3) && !m_FinishedSwapGetup) { // Swap Model - m_FinishedSwap = true; + m_FinishedSwapGetup = true; m_ModelSwapper.m_PastModel = m_ModelSwapper.m_currentModelName; m_ModelSwapper.SwitchModel("Getup", this); } - else if (deltaAngle.y > 0.8 && deltaAngle.x > 0.8 && m_FinishedSwap) + else if (deltaAngle.y > 0.8 && deltaAngle.x > 0.8 && m_FinishedSwapGetup) { // Swap to Original Model - m_FinishedSwap = false; + m_FinishedSwapGetup = false; m_ModelSwapper.SwitchModel(m_ModelSwapper.m_PastModel, this); } diff --git a/Assets/7_Scripts/Waypoint/WaypointManager.cs b/Assets/7_Scripts/Waypoint/WaypointManager.cs index 8f9936e..0522a62 100644 --- a/Assets/7_Scripts/Waypoint/WaypointManager.cs +++ b/Assets/7_Scripts/Waypoint/WaypointManager.cs @@ -146,7 +146,7 @@ public class WaypointManager : MonoBehaviour private void MoveAgentToStartPosition() { m_Agent.position = m_StartingPosition; - Debug.Log($"Moved agent to {m_StartingPosition}"); + //Debug.Log($"Moved agent to {m_StartingPosition}"); } private void CheckOverride() diff --git a/Assets/ML-Agents/Timers/Beep_timers.json b/Assets/ML-Agents/Timers/Beep_timers.json index 9553c41..d1d22d5 100644 --- a/Assets/ML-Agents/Timers/Beep_timers.json +++ b/Assets/ML-Agents/Timers/Beep_timers.json @@ -1 +1 @@ -{"count":1,"self":51.7585024,"total":52.444576999999995,"children":{"InitializeActuators":{"count":1,"self":0.0010004999999999999,"total":0.0010004999999999999,"children":null},"InitializeSensors":{"count":1,"self":0.0015038,"total":0.0015038,"children":null},"AgentSendState":{"count":2346,"self":0.0226373,"total":0.1919807,"children":{"CollectObservations":{"count":470,"self":0.0030171,"total":0.0030171,"children":null},"WriteActionMask":{"count":470,"self":0,"total":0,"children":null},"RequestDecision":{"count":470,"self":0.16632629999999998,"total":0.16632629999999998,"children":null}}},"DecideAction":{"count":2346,"self":0.4700702,"total":0.47406669999999995,"children":{"RayPerceptionSensor.Perceive":{"count":470,"self":0.0039965,"total":0.0039965,"children":null}}},"AgentAct":{"count":2346,"self":0.0175227,"total":0.0175227,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1711381211","unity_version":"2023.2.8f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2023.2.8f1\\Editor\\Unity.exe -projectpath C:\\Users\\Gebruiker\\Documents\\BB_BeautyBeep\\git\\beep-final -useHub -hubIPC -cloudEnvironment production","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.3.0-exp.3","scene_name":"Beep","end_time_seconds":"1711381263"}} \ No newline at end of file +{"count":1,"self":25.245852799999998,"total":25.3366644,"children":{"InitializeActuators":{"count":1,"self":0.001039,"total":0.001039,"children":null},"InitializeSensors":{"count":1,"self":0.0025399,"total":0.0025399,"children":null},"AgentSendState":{"count":78,"self":0.0005122,"total":0.0010245,"children":{"CollectObservations":{"count":16,"self":0,"total":0,"children":null},"WriteActionMask":{"count":16,"self":0,"total":0,"children":null},"RequestDecision":{"count":16,"self":0.00051229999999999993,"total":0.00051229999999999993,"children":null}}},"DecideAction":{"count":78,"self":0.083188,"total":0.083188,"children":{"RayPerceptionSensor.Perceive":{"count":16,"self":0,"total":0,"children":null}}},"AgentAct":{"count":78,"self":0.0030204999999999997,"total":0.0030204999999999997,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1711456890","unity_version":"2023.2.8f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2023.2.8f1\\Editor\\Unity.exe -projectpath C:\\Users\\caile\\Desktop\\Projects\\24_03-Beep\\beep-final -useHub -hubIPC -cloudEnvironment production","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.3.0-exp.3","scene_name":"Beep","end_time_seconds":"1711456916"}} \ No newline at end of file