From 4652b4cbcefabbff9a38360563c69a7bd1c3aa9a Mon Sep 17 00:00:00 2001 From: Cailean Finn Date: Mon, 8 Apr 2024 13:17:02 +0100 Subject: [PATCH] treadmill ramp --- Assets/15_Prefabs/Environment.prefab | 130 +++++++++--------- Assets/15_Prefabs/Waypoints.prefab | 4 +- Assets/6_Scenes/Beep.unity | 51 +++---- .../7_Scripts/Interactable Items/Treadmill.cs | 35 +++-- Assets/ML-Agents/Timers/Beep_timers.json | 2 +- 5 files changed, 105 insertions(+), 117 deletions(-) diff --git a/Assets/15_Prefabs/Environment.prefab b/Assets/15_Prefabs/Environment.prefab index 22adf0c..ecf32a1 100644 --- a/Assets/15_Prefabs/Environment.prefab +++ b/Assets/15_Prefabs/Environment.prefab @@ -304,9 +304,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: be3a6d75d30448c428c5f28690b0f96f, type: 3} m_Name: m_EditorClassIdentifier: - m_MaxForce: 300 + m_HoldSpeed: 0 m_RampTimer: 25 m_RampIncrement: 10 + m_HoldSpeedTimer: 0 --- !u!65 &5329883020623688251 BoxCollider: m_ObjectHideFlags: 0 @@ -15896,6 +15897,66 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 3654837400929340511} m_Modifications: + - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, + type: 3} + propertyPath: m_LocalPosition.x + value: 6.326389 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, + type: 3} + propertyPath: m_LocalPosition.y + value: 11.176942 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, + type: 3} + propertyPath: m_LocalPosition.z + value: 0.19437937 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, + type: 3} + propertyPath: m_LocalRotation.w + value: 0.5815958 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, + type: 3} + propertyPath: m_LocalRotation.x + value: 0.5815959 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, + type: 3} + propertyPath: m_LocalRotation.y + value: 0.40217698 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, + type: 3} + propertyPath: m_LocalRotation.z + value: 0.4021769 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, + type: 3} + propertyPath: m_ConstrainProportionsScale + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 919132149155446097, guid: a2aad9ceeb149fb459fb6000a9f79fd5, + type: 3} + propertyPath: m_Name + value: BB_SpotMini-House_2023-treadmill + objectReference: {fileID: 0} - target: {fileID: 244729283271664975, guid: 4a514862db9328d4895ba96423f9bb05, type: 3} propertyPath: m_Size.y @@ -16048,66 +16109,6 @@ PrefabInstance: value: objectReference: {fileID: 13400000, guid: 1d06c6e01a25d4285bb1a8a8fd89411b, type: 2} - - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, - type: 3} - propertyPath: m_LocalPosition.x - value: 6.326389 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, - type: 3} - propertyPath: m_LocalPosition.y - value: 11.176942 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, - type: 3} - propertyPath: m_LocalPosition.z - value: 0.19437937 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, - type: 3} - propertyPath: m_LocalRotation.w - value: 0.5815958 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, - type: 3} - propertyPath: m_LocalRotation.x - value: 0.5815959 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, - type: 3} - propertyPath: m_LocalRotation.y - value: 0.40217698 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, - type: 3} - propertyPath: m_LocalRotation.z - value: 0.4021769 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: a2aad9ceeb149fb459fb6000a9f79fd5, - type: 3} - propertyPath: m_ConstrainProportionsScale - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 919132149155446097, guid: a2aad9ceeb149fb459fb6000a9f79fd5, - type: 3} - propertyPath: m_Name - value: BB_SpotMini-House_2023-treadmill - objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: @@ -16149,9 +16150,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: be3a6d75d30448c428c5f28690b0f96f, type: 3} m_Name: m_EditorClassIdentifier: - m_MaxForce: 300 - m_RampTimer: 25 - m_RampIncrement: 10 + m_HoldSpeed: 300 + m_RampTimer: 0 + m_RampIncrement: 30 + m_HoldSpeedTimer: 60 --- !u!1001 &8700028673438209428 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/15_Prefabs/Waypoints.prefab b/Assets/15_Prefabs/Waypoints.prefab index 8d522cf..bc1b8e7 100644 --- a/Assets/15_Prefabs/Waypoints.prefab +++ b/Assets/15_Prefabs/Waypoints.prefab @@ -1019,7 +1019,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a5c81c2052c91a74a8d9fae388fca038, type: 3} m_Name: m_EditorClassIdentifier: - m_StartingPosition: 1 + m_StartingPosition: 0 m_WaypointPosition: {fileID: 1170441306195283109} m_WaitTime: 0 m_ModelName: Treadmill @@ -1546,7 +1546,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_StartingPosition: 0 m_WaypointPosition: {fileID: 7419875685076643595} - m_WaitTime: 0 + m_WaitTime: 20 m_ModelName: Treadmill m_Index: 1 m_Touched: 0 diff --git a/Assets/6_Scenes/Beep.unity b/Assets/6_Scenes/Beep.unity index a92323f..639aa22 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: 7710.423, g: 8946.3955, b: 9699.29, a: 1} + m_IndirectSpecularColor: {r: 7710.4307, g: 8946.3955, b: 9699.29, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -671,7 +671,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 83569712} serializedVersion: 2 - m_LocalRotation: {x: -0.2639988, y: -0.16721062, z: 0.07488976, w: 0.9469618} + m_LocalRotation: {x: 0.045081474, y: -0.8875922, z: 0.42261943, w: -0.17759675} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -1245,7 +1245,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 155411616} serializedVersion: 2 - m_LocalRotation: {x: -0.19266106, y: -0.16116163, z: 0.0871481, w: 0.9640093} + m_LocalRotation: {x: 0.03171485, y: -0.85361236, z: 0.48761967, w: -0.18046357} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -2476,7 +2476,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &358130662 Transform: m_ObjectHideFlags: 0 @@ -4215,7 +4215,7 @@ Camera: m_Iso: 50 m_ShutterSpeed: 0.002 m_Aperture: 3.6 - m_FocusDistance: 6.3245645 + m_FocusDistance: 6.3245435 m_FocalLength: 35.000004 m_BladeCount: 5 m_Curvature: {x: 26.748837, y: 32} @@ -4257,8 +4257,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 470663197} serializedVersion: 2 - m_LocalRotation: {x: 0.0020802282, y: 0.9959924, z: -0.08611642, w: 0.024059193} - m_LocalPosition: {x: 11.18338, y: -7.580722, z: -28.978973} + m_LocalRotation: {x: 0.086117, y: -0.02407322, z: 0.0020814561, w: 0.995992} + m_LocalPosition: {x: 9.919113, y: -4.307354, z: -2.8405762} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -4644,8 +4644,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 513050371} serializedVersion: 2 - m_LocalRotation: {x: 0.00807205, y: 0.930002, z: -0.3668959, w: 0.020460904} - m_LocalPosition: {x: 11.041687, y: -6.5707216, z: -26.462921} + m_LocalRotation: {x: 0.11451177, y: -0.021367181, z: 0.0024635731, w: 0.99318904} + m_LocalPosition: {x: 10.035126, y: -3.2973547, z: -5.35791} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -5280,7 +5280,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 562470283} serializedVersion: 2 - m_LocalRotation: {x: -0.042173333, y: 0.90948004, z: -0.40247422, w: -0.09530003} + m_LocalRotation: {x: 0.42771065, y: -0.5667285, z: 0.44248822, w: 0.54780173} m_LocalPosition: {x: 19.623474, y: 33.692642, z: 3.4919434} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -9913,7 +9913,7 @@ Transform: m_GameObject: {fileID: 1124157896} serializedVersion: 2 m_LocalRotation: {x: -0.051868558, y: 0.9246109, z: -0.34594372, w: -0.1507558} - m_LocalPosition: {x: 11.18338, y: -7.580722, z: -28.978973} + m_LocalPosition: {x: 9.919113, y: -4.307354, z: -2.8405762} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -10336,7 +10336,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1178814724} serializedVersion: 2 - m_LocalRotation: {x: -0.19266106, y: -0.16116163, z: 0.0871481, w: 0.9640093} + m_LocalRotation: {x: 0.03171485, y: -0.85361236, z: 0.48761967, w: -0.18046357} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -16572,7 +16572,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &2144310387 Transform: m_ObjectHideFlags: 0 @@ -16680,16 +16680,6 @@ PrefabInstance: propertyPath: m_Index value: 10 objectReference: {fileID: 0} - - target: {fileID: 1835509932309003796, guid: 796c0c7bfd2e89547bd866eedcc6d386, - type: 3} - propertyPath: m_Index - value: 3 - objectReference: {fileID: 0} - - target: {fileID: 1835509932309003796, guid: 796c0c7bfd2e89547bd866eedcc6d386, - type: 3} - propertyPath: m_WaitTime - value: 20 - objectReference: {fileID: 0} - target: {fileID: 2373725966459795291, guid: 796c0c7bfd2e89547bd866eedcc6d386, type: 3} propertyPath: m_Name @@ -16733,7 +16723,7 @@ PrefabInstance: - target: {fileID: 3582199055929070180, guid: 796c0c7bfd2e89547bd866eedcc6d386, type: 3} propertyPath: m_IsActive - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 3919871190456335841, guid: 796c0c7bfd2e89547bd866eedcc6d386, type: 3} @@ -16795,20 +16785,10 @@ PrefabInstance: propertyPath: m_ModelName value: Walker objectReference: {fileID: 0} - - target: {fileID: 5682263026450292309, guid: 796c0c7bfd2e89547bd866eedcc6d386, - type: 3} - propertyPath: m_Index - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 5682263026450292309, guid: 796c0c7bfd2e89547bd866eedcc6d386, - type: 3} - propertyPath: m_Touched - value: 0 - objectReference: {fileID: 0} - target: {fileID: 5682263026450292309, guid: 796c0c7bfd2e89547bd866eedcc6d386, type: 3} propertyPath: m_StartingPosition - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 6150440660435852038, guid: 796c0c7bfd2e89547bd866eedcc6d386, type: 3} @@ -18025,6 +18005,7 @@ PrefabInstance: - {fileID: 2167618697346179678, guid: 14d8283abcefffd4a916b8611ccd49fa, type: 3} - {fileID: 8305524772526707101, guid: 14d8283abcefffd4a916b8611ccd49fa, type: 3} - {fileID: 8564795315029396247, guid: 14d8283abcefffd4a916b8611ccd49fa, type: 3} + - {fileID: 8136213490028637097, guid: 14d8283abcefffd4a916b8611ccd49fa, type: 3} m_RemovedGameObjects: [] m_AddedGameObjects: - targetCorrespondingSourceObject: {fileID: 3006033085249723243, guid: 14d8283abcefffd4a916b8611ccd49fa, diff --git a/Assets/7_Scripts/Interactable Items/Treadmill.cs b/Assets/7_Scripts/Interactable Items/Treadmill.cs index 591f0e8..bc0f4ec 100644 --- a/Assets/7_Scripts/Interactable Items/Treadmill.cs +++ b/Assets/7_Scripts/Interactable Items/Treadmill.cs @@ -7,7 +7,9 @@ using UnityEngine; public class Treadmill : MonoBehaviour { //public Rigidbody m_Body; - public float m_MaxForce; + public float m_HoldSpeed; + + private float m_CurrentForce = 0f; private float m_angleOffset; @@ -17,11 +19,13 @@ public class Treadmill : MonoBehaviour public float m_RampIncrement; + public float m_HoldSpeedTimer; + private void OnEnable() { OnChairContact.ApplyTreadmillForce += ApplyForce; OnChairContact.RemoveTreadmillForce += RemoveForce; - m_angleOffset = 20f; + m_angleOffset = 16.6f; } private void OnDisable() @@ -33,24 +37,31 @@ public class Treadmill : MonoBehaviour public void ApplyForce(Rigidbody rb) { Vector3 forceDirection = Quaternion.Euler(0, -m_angleOffset, 0) * Vector3.forward; - //Debug.Log($"Force added to {rb.name} {forceDirection * m_MaxForce}"); - rb.AddForce(forceDirection * m_MaxForce); + if (!m_RampActive && m_RampTimer > 0f) { m_RampTimer -= Time.deltaTime; - } + } else { m_RampActive = true; } - if( m_RampActive ) + if (m_RampActive) { - m_MaxForce += Time.deltaTime * m_RampIncrement; - } - Debug.Log($"Treadmill Speed: {m_MaxForce}"); + if (m_CurrentForce > m_HoldSpeed && m_HoldSpeedTimer >= 0) + { + m_HoldSpeedTimer -= Time.deltaTime; + } + else + { + m_CurrentForce += Time.deltaTime * m_RampIncrement; + } + + rb.AddForce(forceDirection * m_CurrentForce); + } } @@ -59,12 +70,6 @@ public class Treadmill : MonoBehaviour rb.AddForce(new Vector3(0, 0, 0)); } - private void FixedUpdate() - { - //Debug.Log($"Applying Force {m_Force}"); - //m_Force = (m_Force < 0f) ? 0 : (m_Force > m_MaxForce) ? m_MaxForce : m_Force; - } - private void OnDrawGizmosSelected() { // Draw a line representing the force direction diff --git a/Assets/ML-Agents/Timers/Beep_timers.json b/Assets/ML-Agents/Timers/Beep_timers.json index ab8948d..5410731 100644 --- a/Assets/ML-Agents/Timers/Beep_timers.json +++ b/Assets/ML-Agents/Timers/Beep_timers.json @@ -1 +1 @@ -{"count":1,"self":158.6874624,"total":159.9239869,"children":{"InitializeActuators":{"count":1,"self":0.0010027,"total":0.0010027,"children":null},"InitializeSensors":{"count":1,"self":0.0015065999999999999,"total":0.0015065999999999999,"children":null},"AgentSendState":{"count":7679,"self":0.0845993,"total":0.1371532,"children":{"CollectObservations":{"count":1536,"self":0.045376599999999996,"total":0.045376599999999996,"children":null},"WriteActionMask":{"count":1536,"self":0.0021577,"total":0.0021577,"children":null},"RequestDecision":{"count":1536,"self":0.0050196,"total":0.0050196,"children":null}}},"DecideAction":{"count":7679,"self":1.0351363999999998,"total":1.0481768,"children":{"RayPerceptionSensor.Perceive":{"count":1536,"self":0.013040399999999999,"total":0.013040399999999999,"children":null}}},"AgentAct":{"count":7679,"self":0.0486889,"total":0.0486889,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1712570190","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":"1712570350"}} \ No newline at end of file +{"count":1,"self":29.9055488,"total":30.5298308,"children":{"InitializeActuators":{"count":1,"self":0.001006,"total":0.001006,"children":null},"InitializeSensors":{"count":1,"self":0.0020058,"total":0.0020058,"children":null},"AgentSendState":{"count":1189,"self":0.0142451,"total":0.33428379999999996,"children":{"CollectObservations":{"count":238,"self":0.0071046999999999994,"total":0.0071046999999999994,"children":null},"WriteActionMask":{"count":238,"self":0,"total":0,"children":null},"RequestDecision":{"count":238,"self":0.312934,"total":0.312934,"children":null}}},"DecideAction":{"count":1189,"self":0.26906769999999997,"total":0.2726116,"children":{"RayPerceptionSensor.Perceive":{"count":238,"self":0.0035439,"total":0.0035439,"children":null}}},"AgentAct":{"count":1189,"self":0.0143758,"total":0.0143758,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1712578559","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":"1712578590"}} \ No newline at end of file