diff --git a/Assets/Scenes/Testing Scenes/YeetScene.unity b/Assets/Scenes/Testing Scenes/YeetScene.unity index 0fb8847..e40e4c1 100644 --- a/Assets/Scenes/Testing Scenes/YeetScene.unity +++ b/Assets/Scenes/Testing Scenes/YeetScene.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:591ff66476d7a4ed20246a21b182793f83ee71fd0cb3d3b68dd80a74078c5995 -size 15783 +oid sha256:080a4826fd4774c2565e7497889f27197b961d87411803318c5e53f20985adf6 +size 16523 diff --git a/Assets/Scripts/Behaviours/YeetController.cs b/Assets/Scripts/Behaviours/YeetController.cs index a0874f3..17e8588 100644 --- a/Assets/Scripts/Behaviours/YeetController.cs +++ b/Assets/Scripts/Behaviours/YeetController.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using UnityEngine; -public class YeetController : MonoBehaviour, IYeetable +public class YeetController : MonoBehaviour { public GameObject parent { get; set; } @@ -19,7 +19,6 @@ public class YeetController : MonoBehaviour, IYeetable { _child = child; _child.transform.parent = parent.transform; - yeetState = YeetState.Held; } @@ -27,6 +26,7 @@ public class YeetController : MonoBehaviour, IYeetable { _child.transform.parent = null; _child.transform.rotation = parent.transform.rotation; + _child.GetComponent().velocity = _child.transform.forward * yeetVelocity; yeetState = YeetState.Yeeting; _time = yeetDuration; } @@ -43,11 +43,12 @@ public class YeetController : MonoBehaviour, IYeetable switch(yeetState) { case YeetState.Yeeting: - _child.transform.position += _child.transform.forward * yeetVelocity * Time.deltaTime; + //_child.transform.position += _child.transform.forward * yeetVelocity * Time.deltaTime; _time -= Time.deltaTime; if(_time <= 0f) { + Debug.Log("YeetController.Update: Yeet finished"); yeetState = YeetState.Unheld; } break; diff --git a/Assets/Scripts/Player Scripts/PlayerInputController.cs b/Assets/Scripts/Player Scripts/PlayerInputController.cs index 0fee96f..dc922d9 100644 --- a/Assets/Scripts/Player Scripts/PlayerInputController.cs +++ b/Assets/Scripts/Player Scripts/PlayerInputController.cs @@ -30,8 +30,8 @@ public class PlayerInputController : MonoBehaviour private YeetController m_yeetController; - public GameObject child; - public GameObject body; + private GameObject m_child; + private GameObject m_body; private void Awake() { @@ -39,7 +39,7 @@ public class PlayerInputController : MonoBehaviour m_controller = GetComponent(); m_yeetController = GetComponent(); - body = this.gameObject; + m_body = this.gameObject; } @@ -59,23 +59,23 @@ public class PlayerInputController : MonoBehaviour private void OnTriggerEnter(Collider collider) { - Debug.Log("Bang!"); - child = collider.gameObject; + Debug.Log("PlayerInputController.OnTriggerEnter: arrived"); + m_child = collider.gameObject; } private void OnTriggerExit(Collider collider) { - child = null; + m_child = null; } private void OnYeet() { - m_yeetController.parent = body; + m_yeetController.parent = m_body; switch (m_yeetController.yeetState) { case YeetController.YeetState.Unheld: - if(child) - m_yeetController.Hold(child); + if(m_child) + m_yeetController.Hold(m_child); // Grab nearest baby break; case YeetController.YeetState.Held: diff --git a/Assets/YeetHandle.cs b/Assets/YeetHandle.cs new file mode 100644 index 0000000..1456e36 --- /dev/null +++ b/Assets/YeetHandle.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class YeetHandle : MonoBehaviour +{ + private BoxCollider m_handleArea; + + // Start is called before the first frame update + void Start() + { + m_handleArea = gameObject.AddComponent(); + + m_handleArea.isTrigger = true; + m_handleArea.size = new Vector3(2, 2, 2); + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/YeetHandle.cs.meta b/Assets/YeetHandle.cs.meta new file mode 100644 index 0000000..9420351 --- /dev/null +++ b/Assets/YeetHandle.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a18fca169b45e1642b530ee6dc555240 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: