diff --git a/Assets/Scenes/BoatTest.unity b/Assets/Scenes/BoatTest.unity index 585a17e..c049596 100644 --- a/Assets/Scenes/BoatTest.unity +++ b/Assets/Scenes/BoatTest.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:51c8759d1d74c0e958bb8df7ddfd88a5e93a301bf4e288b3bd02954940af9ae5 -size 47470 +oid sha256:4d0ec36d9b37bf7a9f684f834da6ee33b8b7a939bdbe265adf551380dfce347f +size 73717 diff --git a/Assets/Scenes/Development/CharacterControllerTest.unity b/Assets/Scenes/Development/CharacterControllerTest.unity index 25594ff..c8f91d9 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:34c8292f5ef22102555eef0f0a820c829060b275d8b13ed4b85ab4a5b567c37c -size 22923 +oid sha256:24894f68749013207500f5f502e5ef2753c5be9a2b2b74009445948336e95510 +size 8513 diff --git a/Assets/Scenes/Utility.meta b/Assets/Scenes/Utility.meta new file mode 100644 index 0000000..9385599 --- /dev/null +++ b/Assets/Scenes/Utility.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f29057d258e1d49459df24e6862140e7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Utility/CopyTransform.cs b/Assets/Scenes/Utility/CopyTransform.cs new file mode 100644 index 0000000..d625d03 --- /dev/null +++ b/Assets/Scenes/Utility/CopyTransform.cs @@ -0,0 +1,87 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using NaughtyAttributes; + + +/// +/// Utility script to fake parent an object to another +/// +public class CopyTransform : MonoBehaviour +{ + + #region Inspector Fields + [SerializeField, BoxGroup("References")] + public Transform m_target; + + [SerializeField, Range(0, 1)] + public float m_dampening = 1; + #endregion Inspector Fields + + #region Private Fields + + private Vector3 m_positionOffset; + private Quaternion m_rotationOffset; + + + #endregion Private Fields + + #region Getters + + #endregion Getters + + + + #region MonoBehaviour Functions + + private void Awake() + { + m_positionOffset = transform.position - m_target.position; + m_rotationOffset = m_target.rotation * Quaternion.Inverse(transform.rotation); + } + + /// + /// 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() + { + Vector3 expectedPosition = m_target.position + (m_target.rotation * m_positionOffset); + Quaternion expectedRotation = m_target.rotation * m_rotationOffset; + + transform.position = Vector3.Lerp(transform.position, expectedPosition, m_dampening); + transform.rotation = Quaternion.Lerp(transform.rotation, expectedRotation, m_dampening); + } + + #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/Scenes/Utility/CopyTransform.cs.meta b/Assets/Scenes/Utility/CopyTransform.cs.meta new file mode 100644 index 0000000..614532a --- /dev/null +++ b/Assets/Scenes/Utility/CopyTransform.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 402a55c05df6014479f29432c30e3873 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/BoatController.cs b/Assets/Scripts/BoatController.cs index ed2142e..b2681bf 100644 --- a/Assets/Scripts/BoatController.cs +++ b/Assets/Scripts/BoatController.cs @@ -13,6 +13,9 @@ public class BoatController : MonoBehaviour [SerializeField] private float BrakeFactor = 1f; + [SerializeField] + private bool m_usedebugkeys; + void Awake() { rigidBody = GetComponent(); @@ -21,6 +24,9 @@ public class BoatController : MonoBehaviour // Update is called once per frame void Update() { + if (!m_usedebugkeys) + return; + //get input if (Input.GetKeyDown(KeyCode.A)) { @@ -38,7 +44,7 @@ public class BoatController : MonoBehaviour private void FixedUpdate() { - print(transform.rotation.eulerAngles.y); + //print(transform.rotation.eulerAngles.y); //constrain rotation if (transform.rotation.eulerAngles.y > 180 && transform.rotation.eulerAngles.y < 270) { diff --git a/Assets/Scripts/Player/BoatRowController.cs b/Assets/Scripts/Player/BoatRowController.cs index 33f0c18..b496617 100644 --- a/Assets/Scripts/Player/BoatRowController.cs +++ b/Assets/Scripts/Player/BoatRowController.cs @@ -2,7 +2,8 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using NaughtyAttributes; - +using Unity.VisualScripting; +using UnityEngine.Events; /// /// @@ -11,8 +12,8 @@ public class BoatRowController : MonoBehaviour { #region Inspector Fields - public Collider m_oar; public Transform m_oarTip; + public UnityEvent m_OnRow; #endregion Inspector Fields #region Private Fields @@ -56,21 +57,38 @@ public class BoatRowController : MonoBehaviour private void OnTriggerEnter(Collider other) { - if(other == m_oar) + OarController oar = other.GetComponentInParent(); + if (oar != null) { - m_lastKnownOarPosition = m_oarTip.position; + m_lastKnownOarPosition = m_oarTip.localPosition; } } void OnTriggerStay(Collider other) { - if(other == m_oar) + OarController oar = other.GetComponentInParent(); + if(oar != null) { - Vector3 direction = m_lastKnownOarPosition - m_oarTip.position; - direction = Vector3.Project(direction,transform.forward); - - - } + Vector3 direction = m_lastKnownOarPosition - m_oarTip.localPosition; + + float directionality = Vector3.Dot(direction,Vector3.forward); + + if (directionality > 0) + { + Debug.Log($"Row! ({directionality})"); + m_OnRow.Invoke(); + } + else + { + Debug.Log($"No Row: {directionality}"); + } + m_lastKnownOarPosition=m_oarTip.localPosition; + } + else + { + Debug.Log($"Not Oar: {other.gameObject}"); + } + } diff --git a/Assets/Scripts/Player/HandController.cs b/Assets/Scripts/Player/HandController.cs index f8f7aa6..c2d130f 100644 --- a/Assets/Scripts/Player/HandController.cs +++ b/Assets/Scripts/Player/HandController.cs @@ -116,7 +116,7 @@ public class HandController : MonoBehaviour Quaternion rotation = Quaternion.LookRotation(m_axisForward.normalized, m_axisNormal.normalized); - Vector3 axisInput = transform.rotation * rotation * new Vector3(input.x, 0, input.y); + Vector3 axisInput = rotation * new Vector3(input.x, 0, input.y); Vector3 desiredPosition = m_startPosition + axisInput * m_armRange; transform.localPosition = Vector3.Lerp(transform.localPosition, desiredPosition, m_armSpeed); diff --git a/Assets/Scripts/Player/OarController.cs b/Assets/Scripts/Player/OarController.cs index af87e89..3466863 100644 --- a/Assets/Scripts/Player/OarController.cs +++ b/Assets/Scripts/Player/OarController.cs @@ -99,8 +99,8 @@ public class OarController : MonoBehaviour 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); + //m_oarRigidbody.MoveRotation(rotation); + //m_oarRigidbody.MovePosition(m_rightHand.transform.position - direction * m_distanceFromRightHand); //MoveOarToRotation(rotation); @@ -128,33 +128,19 @@ 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($"Forbidden collision: {string.Join(", ", col.Intersect(m_forbiddenColliders))}"); return true; } - return false; - - - } - -/* - void OnCollisionEnter(Collision collision) - { - - if (m_forbiddenColliders.Contains(collision.collider) && !undoDoneThisFrame) - { - Debug.Log($"Forbidden Collision: {collision.collider.gameObject}"); - undoDoneThisFrame= true; - m_leftHand.UndoLastMovement(); - m_rightHand.UndoLastMovement(); - } else { - Debug.Log($"Ignored Collision: {collision.collider.gameObject}"); + // Debug.Log($"Ignored collision: {string.Join(", ", col.Except(m_forbiddenColliders))}"); } + return false; + } + - }*/ #endregion Class Functionality diff --git a/Assets/Scripts/Player/PlayerController.cs b/Assets/Scripts/Player/PlayerController.cs index d86929c..9f17d39 100644 --- a/Assets/Scripts/Player/PlayerController.cs +++ b/Assets/Scripts/Player/PlayerController.cs @@ -36,7 +36,7 @@ public class PlayerController : MonoBehaviour /// private void OnEnable() { - + rightHand.UpdateHand(Vector2.up); } /// @@ -52,17 +52,20 @@ public class PlayerController : MonoBehaviour /// private void FixedUpdate() { - leftHand.UpdateHand(leftHand.m_desiredInput); - rightHand.UpdateHand(rightHand.m_desiredInput); - - oar.UpdateTransform(); if (oar.isColliding()) { leftHand.UndoLastMovement(); rightHand.UndoLastMovement(); - + oar.UpdateTransform(); } + + leftHand.UpdateHand(leftHand.m_desiredInput); + rightHand.UpdateHand(rightHand.m_desiredInput); + + oar.UpdateTransform(); + + } #endregion MonoBehaviour Functions diff --git a/ProjectSettings/DynamicsManager.asset b/ProjectSettings/DynamicsManager.asset index 6827b69..0d97b04 100644 --- a/ProjectSettings/DynamicsManager.asset +++ b/ProjectSettings/DynamicsManager.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c180f985770287728278a4dc939c76a04d76b519697ff906c33d202fd44e1a1e +oid sha256:e127c9b4d8872ac4c7ae7092ef6f2120283433c01c397e1a3344c2f851a4d1f6 size 1323 diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 0c8c80b..6e981f6 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:28529725e71fa58fdb2277e07306508472f8b936b0c5a6b386c90f1f4d415453 -size 390 +oid sha256:257adc2e17b69e053a710c5d8e6a52820e964684ee546ec36f9411e1609b7055 +size 394