diff --git a/Assets/Baby.prefab b/Assets/Baby.prefab index 5976dcf..a4714e3 100644 --- a/Assets/Baby.prefab +++ b/Assets/Baby.prefab @@ -107,7 +107,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1559629916365419313} - m_LocalRotation: {x: -0.000000016727624, y: 0.92387956, z: 0.38268343, w: -0.00000004038406} + m_LocalRotation: {x: 0.1308854, y: 0.8681629, z: 0.31598538, w: -0.35960484} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0.1, y: 0.1, z: 0.1} m_Children: @@ -419,6 +419,7 @@ GameObject: - component: {fileID: 2698261171203200709} - component: {fileID: 8095308533274768900} - component: {fileID: 3309192074068051052} + - component: {fileID: 933390416532010} m_Layer: 0 m_Name: Baby m_TagString: Untagged @@ -538,6 +539,18 @@ MonoBehaviour: faceObj: {fileID: 1577162025261597670} topObj: {fileID: 6588930193113420027} bottomObj: {fileID: 4834944236669872262} +--- !u!114 &933390416532010 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6037890115969564912} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a18fca169b45e1642b530ee6dc555240, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &6085469794438535834 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/BabyController.cs b/Assets/Scripts/BabyController.cs index 1da647d..3973276 100644 --- a/Assets/Scripts/BabyController.cs +++ b/Assets/Scripts/BabyController.cs @@ -9,6 +9,8 @@ public class BabyController : MonoBehaviour public Vector3 targetVector; private Rigidbody rb; + private YeetHandle yeetHandle; + public float speed; private float timer = 0; @@ -19,6 +21,7 @@ public class BabyController : MonoBehaviour void Start() { rb = GetComponent(); + yeetHandle = GetComponent(); currentVector = RandomNormVector(); targetVector = RandomNormVector(); @@ -28,8 +31,13 @@ public class BabyController : MonoBehaviour void FixedUpdate() { - currentVector = Vector3.Slerp(currentVector, targetVector, Time.deltaTime); - rb.MovePosition(transform.position + (currentVector * speed)); + + if(!yeetHandle.held) + { + currentVector = Vector3.Slerp(currentVector, targetVector, Time.deltaTime); + rb.MovePosition(transform.position + (currentVector * speed)); + } + timer += Time.deltaTime; if (timer > randTimer) diff --git a/Assets/Scripts/Behaviours/YeetController.cs b/Assets/Scripts/Behaviours/YeetController.cs index 42f8345..c379355 100644 --- a/Assets/Scripts/Behaviours/YeetController.cs +++ b/Assets/Scripts/Behaviours/YeetController.cs @@ -32,6 +32,8 @@ public class YeetController : MonoBehaviour { _child = child; _child.transform.parent = parent.transform; + _child.GetComponent().held = true; + yeetState = YeetState.Held; m_lineRenderer = gameObject.AddComponent(); @@ -41,6 +43,8 @@ public class YeetController : MonoBehaviour { _child.transform.parent = null; _child.transform.rotation = parent.transform.rotation; + _child.GetComponent().held = true; + _child.GetComponent().velocity = _child.transform.forward * m_velocityWindup + _child.transform.up * m_velocityWindup; yeetState = YeetState.Yeeting; m_time = yeetDuration; diff --git a/Assets/Scripts/Behaviours/YeetHandle.cs b/Assets/Scripts/Behaviours/YeetHandle.cs index 1456e36..e8165ce 100644 --- a/Assets/Scripts/Behaviours/YeetHandle.cs +++ b/Assets/Scripts/Behaviours/YeetHandle.cs @@ -6,6 +6,8 @@ public class YeetHandle : MonoBehaviour { private BoxCollider m_handleArea; + public bool held { get; set; } + // Start is called before the first frame update void Start() { @@ -20,4 +22,5 @@ public class YeetHandle : MonoBehaviour { } + } diff --git a/Assets/Scripts/LookAtCamera.cs b/Assets/Scripts/LookAtCamera.cs index fcdd7ea..cf42f49 100644 --- a/Assets/Scripts/LookAtCamera.cs +++ b/Assets/Scripts/LookAtCamera.cs @@ -17,4 +17,9 @@ public class LookAtCamera : MonoBehaviour transform.rotation = _cameraObj.transform.rotation; transform.Rotate(new Vector3(0, 180, 0)); } + + private void LateUpdate() + { + UpdateRotation(); + } }