diff --git a/Assets/Scenes/Development/CharacterControllerTest.unity b/Assets/Scenes/Development/CharacterControllerTest.unity index 59e9f53..bb4166a 100644 --- a/Assets/Scenes/Development/CharacterControllerTest.unity +++ b/Assets/Scenes/Development/CharacterControllerTest.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7e3fae2868c248532c42cee9b3c5ea07d8e2d334e0c4bc30f316ef1c050c34c9 -size 19170 +oid sha256:0a34ad1f5f427168262f727710e42c70ece3e600a53b591e39835d2c425d426a +size 21726 diff --git a/Assets/Scripts/Player/BoatRowController.cs b/Assets/Scripts/Player/BoatRowController.cs new file mode 100644 index 0000000..33f0c18 --- /dev/null +++ b/Assets/Scripts/Player/BoatRowController.cs @@ -0,0 +1,90 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using NaughtyAttributes; + + +/// +/// +/// +public class BoatRowController : MonoBehaviour +{ + + #region Inspector Fields + public Collider m_oar; + public Transform m_oarTip; + #endregion Inspector Fields + + #region Private Fields + private Vector3 m_lastKnownOarPosition; + #endregion Private Fields + + #region Getters + + #endregion Getters + + + + #region MonoBehaviour Functions + /// + /// OnEnable is called when the object becomes enabled and active. + /// + private void OnEnable() + { + + } + + /// + /// OnDisable is called when the behaviour becomes disabled. + /// + private void OnDisable() + { + + } + + /// + /// Update is called once per frame + /// + private void Update() + { + + } + + #endregion MonoBehaviour Functions + + #region Class Functionality + + private void OnTriggerEnter(Collider other) + { + if(other == m_oar) + { + m_lastKnownOarPosition = m_oarTip.position; + } + } + + void OnTriggerStay(Collider other) + { + if(other == m_oar) + { + Vector3 direction = m_lastKnownOarPosition - m_oarTip.position; + direction = Vector3.Project(direction,transform.forward); + + + } + } + + + + #endregion Class Functionality + + #region Editor Functions + /// + /// Called when the Component is created or Reset from the Inspector + /// + private void Reset() + { + //useful for finding components on creation + } + #endregion Editor Functions + +} \ No newline at end of file diff --git a/Assets/Scripts/Player/BoatRowController.cs.meta b/Assets/Scripts/Player/BoatRowController.cs.meta new file mode 100644 index 0000000..db817a7 --- /dev/null +++ b/Assets/Scripts/Player/BoatRowController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 519e6a3b156d9684f9781dd40072e27a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Player/HandController.cs b/Assets/Scripts/Player/HandController.cs index a1802b8..f8f7aa6 100644 --- a/Assets/Scripts/Player/HandController.cs +++ b/Assets/Scripts/Player/HandController.cs @@ -49,7 +49,7 @@ public class HandController : MonoBehaviour #region Private Fields //Last input of player - private Vector2 m_desiredInput; + public Vector2 m_desiredInput; private Vector3 m_startPosition; private Vector3 m_lastPosition; @@ -97,7 +97,7 @@ public class HandController : MonoBehaviour /// private void FixedUpdate() { - UpdateHand(m_desiredInput); + //UpdateHand(m_desiredInput); } #endregion MonoBehaviour Functions @@ -108,7 +108,7 @@ public class HandController : MonoBehaviour /// Called every fixed update to move the arms /// /// - private void UpdateHand(Vector2 input, bool registerUndo = true) + public void UpdateHand(Vector2 input, bool registerUndo = true) { m_lastPosition = transform.localPosition; @@ -129,8 +129,6 @@ public class HandController : MonoBehaviour } } - if (m_oar.isColliding()) - UndoLastMovement(); } diff --git a/Assets/Scripts/Player/OarController.cs b/Assets/Scripts/Player/OarController.cs index bf8a197..af87e89 100644 --- a/Assets/Scripts/Player/OarController.cs +++ b/Assets/Scripts/Player/OarController.cs @@ -80,15 +80,15 @@ public class OarController : MonoBehaviour /// private void FixedUpdate() { - undoDoneThisFrame = false; - UpdateTransform(); + //undoDoneThisFrame = false; + //UpdateTransform(); } #endregion MonoBehaviour Functions #region Class Functionality - private void UpdateTransform() + public void UpdateTransform() { Vector3 direction =(m_rightHand.transform.position - m_leftHand.transform.position).normalized; @@ -96,6 +96,8 @@ public class OarController : MonoBehaviour Quaternion rotation = Quaternion.LookRotation(forward, direction); + transform.rotation = rotation; + transform.position = m_rightHand.transform.position - direction * m_distanceFromRightHand; //MoveOarToPosition(m_rightHand.transform.position - direction * m_distanceFromRightHand); m_oarRigidbody.MoveRotation(rotation); m_oarRigidbody.MovePosition(m_rightHand.transform.position - direction * m_distanceFromRightHand); @@ -126,7 +128,7 @@ public class OarController : MonoBehaviour Collider[] col = Physics.OverlapBox(transform.position + m_boxCollider.center, m_boxCollider.size / 2, rotation); if (col.Intersect(m_forbiddenColliders).Any()) { - Debug.Log($"Colliding with: {string.Join(", ", col.Intersect(m_forbiddenColliders))}"); + return true; } return false; diff --git a/Assets/Scripts/Player/PlayerController.cs b/Assets/Scripts/Player/PlayerController.cs new file mode 100644 index 0000000..d86929c --- /dev/null +++ b/Assets/Scripts/Player/PlayerController.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using NaughtyAttributes; + + +/// +/// +/// +public class PlayerController : MonoBehaviour +{ + + #region Inspector Fields + public OarController oar; + + public HandController leftHand; + public HandController rightHand; + + + + #endregion Inspector Fields + + #region Private Fields + + #endregion Private Fields + + #region Getters + + #endregion Getters + + + + #region MonoBehaviour Functions + /// + /// OnEnable is called when the object becomes enabled and active. + /// + private void OnEnable() + { + + } + + /// + /// OnDisable is called when the behaviour becomes disabled. + /// + private void OnDisable() + { + + } + + /// + /// Update is called once per frame + /// + private void FixedUpdate() + { + leftHand.UpdateHand(leftHand.m_desiredInput); + rightHand.UpdateHand(rightHand.m_desiredInput); + + oar.UpdateTransform(); + + if (oar.isColliding()) + { + leftHand.UndoLastMovement(); + rightHand.UndoLastMovement(); + + } + } + + #endregion MonoBehaviour Functions + + #region Class Functionality + + #endregion Class Functionality + + #region Editor Functions + /// + /// Called when the Component is created or Reset from the Inspector + /// + private void Reset() + { + //useful for finding components on creation + } + #endregion Editor Functions + +} \ No newline at end of file diff --git a/Assets/Scripts/Player/PlayerController.cs.meta b/Assets/Scripts/Player/PlayerController.cs.meta new file mode 100644 index 0000000..a672bfb --- /dev/null +++ b/Assets/Scripts/Player/PlayerController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c7961a202d27d534bae8d79b6e85a629 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/DynamicsManager.asset b/ProjectSettings/DynamicsManager.asset index 4e96d0e..6827b69 100644 --- a/ProjectSettings/DynamicsManager.asset +++ b/ProjectSettings/DynamicsManager.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:72854f0c15a6f6d760a54b340adf092d405b8c1fb0c6708a972a3a0085d8cb74 +oid sha256:c180f985770287728278a4dc939c76a04d76b519697ff906c33d202fd44e1a1e size 1323