From 639cb88e63802a6810b8a2d761d4da36aceea8e6 Mon Sep 17 00:00:00 2001 From: Pasha Bibko Date: Fri, 28 Mar 2025 13:55:49 +0000 Subject: [PATCH] Now able to look any direction during wall ride Also made a key bind for wallride --- Assets/Scenes/SampleScene.unity | 232 +++++++++--------- Assets/Scripts/Player/PlayerCollisions.cs | 9 + .../Scripts/Player/PlayerCollisions.cs.meta | 11 + Assets/Scripts/Player/PlayerFixedUpdate.cs | 3 + Assets/Scripts/Player/PlayerMovement.cs | 27 +- Assets/Scripts/Player/PlayerState.cs | 2 +- Assets/Scripts/Player/PlayerUpdate.cs | 9 +- Assets/Scripts/Player/WallRunningMovement.cs | 49 +++- 8 files changed, 210 insertions(+), 132 deletions(-) create mode 100644 Assets/Scripts/Player/PlayerCollisions.cs create mode 100644 Assets/Scripts/Player/PlayerCollisions.cs.meta diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 725e55d..2308c68 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -175,7 +175,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1184477 @@ -281,7 +281,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &3704417 @@ -372,7 +372,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &61224839 @@ -478,7 +478,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &80674226 @@ -693,7 +693,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &88803001 @@ -784,7 +784,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &91982770 @@ -905,7 +905,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &92538672 @@ -1011,7 +1011,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &122251922 @@ -1196,7 +1196,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &156169929 @@ -1287,7 +1287,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &165895539 @@ -1439,7 +1439,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &197672794 @@ -1545,7 +1545,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &198569686 @@ -1651,7 +1651,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &233380150 @@ -1844,7 +1844,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &241925891 @@ -1965,7 +1965,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &282366928 @@ -2056,7 +2056,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &294563071 @@ -2177,7 +2177,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &318181809 @@ -2268,7 +2268,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &322757011 @@ -2374,7 +2374,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &346507997 @@ -2495,7 +2495,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &367456056 @@ -2601,7 +2601,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &370119276 @@ -2692,7 +2692,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &377835094 @@ -2813,7 +2813,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &398183289 @@ -2904,7 +2904,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &435088977 @@ -3025,7 +3025,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &443455232 @@ -3131,7 +3131,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &451011279 @@ -3237,7 +3237,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &453349379 @@ -3343,7 +3343,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &454587930 @@ -3434,7 +3434,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &479468694 @@ -3540,7 +3540,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &480920584 @@ -3646,7 +3646,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &486728957 @@ -3767,7 +3767,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &515736271 @@ -3873,7 +3873,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &538274580 @@ -3964,7 +3964,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &541470221 @@ -4085,7 +4085,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &543919277 @@ -4176,7 +4176,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &609667112 @@ -4282,7 +4282,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &623275130 @@ -4388,7 +4388,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &626104097 @@ -4509,7 +4509,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &669538319 @@ -4694,7 +4694,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &720009869 @@ -4800,7 +4800,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &728779908 @@ -4906,7 +4906,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &738550371 @@ -5012,7 +5012,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &754184264 @@ -5133,7 +5133,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &765026732 @@ -5224,7 +5224,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &770639397 @@ -5330,7 +5330,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &784609520 @@ -5534,7 +5534,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &801446443 @@ -5640,7 +5640,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &813608507 @@ -5746,7 +5746,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &819521515 @@ -5852,7 +5852,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &868227307 @@ -5943,7 +5943,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &876770309 @@ -6064,7 +6064,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &877871333 @@ -6155,7 +6155,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &880202222 @@ -6276,7 +6276,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &899779057 @@ -6367,7 +6367,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &907395359 @@ -6473,7 +6473,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &909720219 @@ -6579,7 +6579,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &925178856 @@ -6700,7 +6700,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &931340320 @@ -6791,7 +6791,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &936182653 @@ -6912,7 +6912,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &937168906 @@ -7018,7 +7018,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &938464532 @@ -7232,7 +7232,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &974940783 @@ -7323,7 +7323,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1005571350 @@ -7429,7 +7429,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1006976176 @@ -7550,7 +7550,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1016856843 @@ -7656,7 +7656,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1025007860 @@ -7762,7 +7762,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1038274280 @@ -7853,7 +7853,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1058153468 @@ -7959,7 +7959,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1063971906 @@ -8065,7 +8065,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1093440197 @@ -8186,7 +8186,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1124258153 @@ -8292,7 +8292,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1145078662 @@ -8383,7 +8383,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1157483234 @@ -8489,7 +8489,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1160769876 @@ -8610,7 +8610,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1163424657 @@ -8778,7 +8778,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1204641203 @@ -8884,7 +8884,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1208082009 @@ -8990,7 +8990,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1213172944 @@ -9096,7 +9096,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1214437194 @@ -9187,7 +9187,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1220780383 @@ -9308,7 +9308,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1237184044 @@ -9399,7 +9399,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1246331936 @@ -9505,7 +9505,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1315944179 @@ -9626,7 +9626,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1321695518 @@ -9732,7 +9732,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1337688186 @@ -9823,7 +9823,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1339212880 @@ -9929,7 +9929,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1480667474 @@ -10050,7 +10050,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1505178936 @@ -10156,7 +10156,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1545883018 @@ -10262,7 +10262,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1563287693 @@ -10368,7 +10368,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1603404184 @@ -10459,7 +10459,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1609630767 @@ -10580,7 +10580,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1646977415 @@ -10671,7 +10671,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1658781293 @@ -10792,7 +10792,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1665475734 @@ -10898,7 +10898,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1667041623 @@ -11004,7 +11004,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1695018873 @@ -11110,7 +11110,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1785879028 @@ -11201,7 +11201,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1802538871 @@ -11322,7 +11322,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1814447012 @@ -11428,7 +11428,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1819356659 @@ -11519,7 +11519,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1831516692 @@ -11640,7 +11640,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1837026080 @@ -11746,7 +11746,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1854878173 @@ -11852,7 +11852,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1858166055 @@ -11958,7 +11958,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1861848491 @@ -12064,7 +12064,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1891905259 @@ -12170,7 +12170,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1909029074 @@ -12276,7 +12276,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1916023929 @@ -12367,7 +12367,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1927681505 @@ -12488,7 +12488,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1934720228 @@ -12594,7 +12594,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1949355161 @@ -12685,7 +12685,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1968876057 @@ -12874,7 +12874,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &1998218713 @@ -13112,7 +13112,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &2063778114 @@ -13218,7 +13218,7 @@ MeshCollider: m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 5 - m_Convex: 0 + m_Convex: 1 m_CookingOptions: 30 m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!23 &2085076197 diff --git a/Assets/Scripts/Player/PlayerCollisions.cs b/Assets/Scripts/Player/PlayerCollisions.cs new file mode 100644 index 0000000..236f0e0 --- /dev/null +++ b/Assets/Scripts/Player/PlayerCollisions.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +public partial class PlayerMovement : MonoBehaviour +{ + private void OnTriggerStay(Collider other) + { + m_WallCollisions.Add(other); + } +} diff --git a/Assets/Scripts/Player/PlayerCollisions.cs.meta b/Assets/Scripts/Player/PlayerCollisions.cs.meta new file mode 100644 index 0000000..45df122 --- /dev/null +++ b/Assets/Scripts/Player/PlayerCollisions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8782e0f625dd3a74a9e1fd75478a6688 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Player/PlayerFixedUpdate.cs b/Assets/Scripts/Player/PlayerFixedUpdate.cs index b4c3902..6381e0d 100644 --- a/Assets/Scripts/Player/PlayerFixedUpdate.cs +++ b/Assets/Scripts/Player/PlayerFixedUpdate.cs @@ -78,5 +78,8 @@ public partial class PlayerMovement : MonoBehaviour if (Mathf.Abs(v.y) < 0.1f) { v.y = 0.0f; } if (Mathf.Abs(v.z) < 0.1f) { v.z = 0.0f; } m_Body.velocity = v; + + // Clears all stored collisions + m_WallCollisions.Clear(); } } diff --git a/Assets/Scripts/Player/PlayerMovement.cs b/Assets/Scripts/Player/PlayerMovement.cs index ee57a23..7ae8133 100644 --- a/Assets/Scripts/Player/PlayerMovement.cs +++ b/Assets/Scripts/Player/PlayerMovement.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; @@ -33,6 +34,7 @@ public partial class PlayerMovement : MonoBehaviour [Header("KeyBinds")] [SerializeField] KeyCode m_JumpKey; [SerializeField] KeyCode m_SlideKey; + [SerializeField] KeyCode m_WallRunKey; [Header("References")] [SerializeField] Rigidbody m_Body; @@ -48,6 +50,7 @@ public partial class PlayerMovement : MonoBehaviour // Key state trackers bool m_JumpKeyPressed = false; bool m_SlidingKeyPressed = false; + bool m_WallRunKeyPressed = false; // The direction to move the player Vector3 m_MoveDir; @@ -56,10 +59,6 @@ public partial class PlayerMovement : MonoBehaviour bool m_Grounded = false; bool m_OnSlope = false; - // Trackers for the walls - bool m_HitLhsWall = false; - bool m_HitRhsWall = false; - // Tracks if the distance of the ground is big enough bool m_IsFarEnoughOffGroundToWallRide = false; @@ -69,13 +68,29 @@ public partial class PlayerMovement : MonoBehaviour // Raycast hit objects RaycastHit m_GroundHit; RaycastHit m_SlopeHit; - RaycastHit m_LhsWall; - RaycastHit m_RhsWall; + + // + BoxCollider m_WallCollider; + + // + List m_WallCollisions; + + // + Vector3 m_WallNormal; // Start is called before the first frame update private void Start() { // Stops the rigidbody from rotatating when we don't want it to m_Body.freezeRotation = true; + + // Creates the wall collider + m_WallCollider = gameObject.AddComponent(); + m_WallCollider.size = new Vector3(m_WallCheckDistance * 2, 0.2f, m_WallCheckDistance * 2); + m_WallCollider.providesContacts = true; + m_WallCollider.isTrigger = true; + + // Allocates memory for the list of collisions + m_WallCollisions = new List(); } } diff --git a/Assets/Scripts/Player/PlayerState.cs b/Assets/Scripts/Player/PlayerState.cs index b6960e7..5031e2e 100644 --- a/Assets/Scripts/Player/PlayerState.cs +++ b/Assets/Scripts/Player/PlayerState.cs @@ -19,7 +19,7 @@ public partial class PlayerMovement : MonoBehaviour bool canSlide = !(Mathf.Abs(vel.x) < m_SlideRequiredSpeed && Mathf.Abs(vel.z) < m_SlideRequiredSpeed); // Checks if the player is in the wall running state - if (m_HitLhsWall || m_HitRhsWall) + if (GetNormalOfClosestCollider(out m_WallNormal) && m_WallRunKeyPressed) { m_State = PlayerState.WALL_RUNNING; } // Checks if the player is in the wall riding state diff --git a/Assets/Scripts/Player/PlayerUpdate.cs b/Assets/Scripts/Player/PlayerUpdate.cs index 2b97630..46d8e48 100644 --- a/Assets/Scripts/Player/PlayerUpdate.cs +++ b/Assets/Scripts/Player/PlayerUpdate.cs @@ -9,11 +9,10 @@ public partial class PlayerMovement : MonoBehaviour m_Input.x = Input.GetAxisRaw("Horizontal"); m_Input.y = Input.GetAxisRaw("Vertical"); - // Checks wether the jump button has been pressed + // Updates key press states m_JumpKeyPressed = Input.GetKey(m_JumpKey); - - // Checks wehter the slide key is being pressed m_SlidingKeyPressed = Input.GetKey(m_SlideKey); + m_WallRunKeyPressed = Input.GetKey(m_WallRunKey); } // Applies drag to the player @@ -43,10 +42,6 @@ public partial class PlayerMovement : MonoBehaviour m_Grounded = Physics.Raycast(transform.position, Vector3.down, out m_GroundHit, m_PlayerHeight * 0.5f + 0.3f, m_GroundMask); m_OnSlope = Physics.Raycast(transform.position, Vector3.down, out m_SlopeHit, m_PlayerHeight * 0.5f + 0.3f, m_SlopeMask); - // Checks for walls either side of the player - m_HitLhsWall = Physics.Raycast(transform.position, m_Orientation.right, out m_LhsWall, m_WallCheckDistance, m_GroundMask); - m_HitRhsWall = Physics.Raycast(transform.position, -m_Orientation.right, out m_RhsWall, m_WallCheckDistance, m_GroundMask); - // Checks the player is far enough of the ground to start wall running m_IsFarEnoughOffGroundToWallRide = m_GroundHit.distance > m_DistanceOfFloorToWallRide; diff --git a/Assets/Scripts/Player/WallRunningMovement.cs b/Assets/Scripts/Player/WallRunningMovement.cs index 210511c..d0d5f99 100644 --- a/Assets/Scripts/Player/WallRunningMovement.cs +++ b/Assets/Scripts/Player/WallRunningMovement.cs @@ -2,11 +2,56 @@ using UnityEngine; public partial class PlayerMovement : MonoBehaviour { + bool GetNormalOfClosestCollider(out Vector3 normal) + { + Debug.Log(m_WallCollisions.Count); + + float dist = Mathf.Infinity; + Collider closest = null; + + foreach (Collider collision in m_WallCollisions) + { + Vector3 pos = collision.ClosestPoint(transform.position); + Vector3 dif = transform.position - pos; + + float distance = dif.magnitude; + + dist = Mathf.Min(dist, distance); + + if (dist == distance) + { + closest = collision; + } + } + + if (dist > m_WallCheckDistance) + { + normal = Vector3.zero; + return false; + } + + Vector3 point = closest.ClosestPoint(transform.position); + Vector3 dir = point - transform.position; + + RaycastHit hit; + if (Physics.Raycast(transform.position, dir.normalized, out hit, (m_WallCheckDistance * 2.0f) + 1.0f, m_GroundMask)) + { + normal = hit.normal; + return true; + } + + else + { + Debug.LogError("SOMETHING WENT WRONG"); + normal = Vector3.zero; + return false; + } + } + private void UpdateWallRunState() { // Calculates the foward direction of the wall - Vector3 normal = m_HitRhsWall ? m_RhsWall.normal : m_LhsWall.normal; - Vector3 foward = Vector3.Cross(normal, transform.up); + Vector3 foward = Vector3.Cross(m_WallNormal, transform.up); // Flips the foward direction if facing the other direction if ((m_Orientation.forward - foward).magnitude > (m_Orientation.forward - (-foward)).magnitude)