From 6a03e72f8629d1b6cfe355f6ae3483516932fe18 Mon Sep 17 00:00:00 2001 From: Joshua Reason Date: Sun, 5 Feb 2023 16:08:37 +1100 Subject: [PATCH] Added bump back --- Assets/Materials/ZeroFriction.physicMaterial | 14 +++++++++++++ .../ZeroFriction.physicMaterial.meta | 8 ++++++++ Assets/Scripts/BoatController.cs | 20 +++++++++++++++++++ Assets/Scripts/Player/BoatRowController.cs | 6 +++--- 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 Assets/Materials/ZeroFriction.physicMaterial create mode 100644 Assets/Materials/ZeroFriction.physicMaterial.meta diff --git a/Assets/Materials/ZeroFriction.physicMaterial b/Assets/Materials/ZeroFriction.physicMaterial new file mode 100644 index 0000000..1606dce --- /dev/null +++ b/Assets/Materials/ZeroFriction.physicMaterial @@ -0,0 +1,14 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!134 &13400000 +PhysicMaterial: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: ZeroFriction + dynamicFriction: 0.6 + staticFriction: 0.6 + bounciness: 0 + frictionCombine: 0 + bounceCombine: 0 diff --git a/Assets/Materials/ZeroFriction.physicMaterial.meta b/Assets/Materials/ZeroFriction.physicMaterial.meta new file mode 100644 index 0000000..b81a945 --- /dev/null +++ b/Assets/Materials/ZeroFriction.physicMaterial.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d850cf529f814714ab7042b4428b42ec +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 13400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/BoatController.cs b/Assets/Scripts/BoatController.cs index 6c55434..239158f 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 float ObstacleBounce = 2f; + [SerializeField] private bool m_usedebugkeys; @@ -91,4 +94,21 @@ public class BoatController : MonoBehaviour rigidBody.AddForce(rigidBody.velocity * - BrakeFactor); rigidBody.AddTorque(rigidBody.angularVelocity * -BrakeFactor); } + + public void OnCollisionEnter(Collision collision) + { + if (collision.gameObject.CompareTag("Obstacle")) + { + + Debug.Log($"Hitting: {collision.gameObject} Foce: {collision.impulse * ObstacleBounce}"); + + rigidBody.AddForce(collision.impulse * ObstacleBounce, ForceMode.Impulse); + + + + } + + + } + } diff --git a/Assets/Scripts/Player/BoatRowController.cs b/Assets/Scripts/Player/BoatRowController.cs index 7d3771f..6868a09 100644 --- a/Assets/Scripts/Player/BoatRowController.cs +++ b/Assets/Scripts/Player/BoatRowController.cs @@ -104,17 +104,17 @@ public class BoatRowController : MonoBehaviour if(averageVelocity < 0.000001) { m_OnBrake.Invoke(); - Debug.Log($"Brake! ({averageVelocity})"); + //Debug.Log($"Brake! ({averageVelocity})"); } else { - Debug.Log($"Row! ({averageVelocity})"); + //Debug.Log($"Row! ({averageVelocity})"); m_OnRow.Invoke(averageVelocity); } } else { - Debug.Log($"No Row: {averageVelocity}"); + //Debug.Log($"No Row: {averageVelocity}"); m_OnBrake.Invoke(); } m_lastKnownOarPosition = localOarTipPosition;