From e95c8897f0f586fb219d228cebe8a8217a37442a Mon Sep 17 00:00:00 2001 From: RochesterX Date: Mon, 13 Jan 2025 14:15:28 -0500 Subject: [PATCH 1/4] Remove test folder --- Assets/New Folder For Testing.meta | 8 -------- Assets/New Folder For Testing/Test.cs | 16 ---------------- Assets/New Folder For Testing/Test.cs.meta | 2 -- 3 files changed, 26 deletions(-) delete mode 100644 Assets/New Folder For Testing.meta delete mode 100644 Assets/New Folder For Testing/Test.cs delete mode 100644 Assets/New Folder For Testing/Test.cs.meta diff --git a/Assets/New Folder For Testing.meta b/Assets/New Folder For Testing.meta deleted file mode 100644 index 0f205ef..0000000 --- a/Assets/New Folder For Testing.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 902a3e40c4fe7c64690b99710e736c55 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/New Folder For Testing/Test.cs b/Assets/New Folder For Testing/Test.cs deleted file mode 100644 index 86752c9..0000000 --- a/Assets/New Folder For Testing/Test.cs +++ /dev/null @@ -1,16 +0,0 @@ -using UnityEngine; - -public class Test : MonoBehaviour -{ - // Start is called once before the first execution of Update after the MonoBehaviour is created - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } -} diff --git a/Assets/New Folder For Testing/Test.cs.meta b/Assets/New Folder For Testing/Test.cs.meta deleted file mode 100644 index 19ce88b..0000000 --- a/Assets/New Folder For Testing/Test.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: ca02decb56ef91c40af52d499e1659c0 \ No newline at end of file From 4be2e20865b178e43e1be1bcb2051e02fbfd5664 Mon Sep 17 00:00:00 2001 From: RochesterX Date: Mon, 13 Jan 2025 15:58:50 -0500 Subject: [PATCH 2/4] Make platformer player movement 100% physics-based --- .../Games/Platformer/Ground.physicsMaterial2D | 14 +++++++++++ .../Platformer/Ground.physicsMaterial2D.meta | 8 ++++++ .../Games/Platformer/Platformer Player.prefab | 4 ++- .../Platformer/PlatformerPlayerMovement.cs | 25 +++++++++++++++---- .../Games/Platformer/Player.physicsMaterial2D | 14 +++++++++++ .../Platformer/Player.physicsMaterial2D.meta | 8 ++++++ 6 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 Assets/Games/Platformer/Ground.physicsMaterial2D create mode 100644 Assets/Games/Platformer/Ground.physicsMaterial2D.meta create mode 100644 Assets/Games/Platformer/Player.physicsMaterial2D create mode 100644 Assets/Games/Platformer/Player.physicsMaterial2D.meta diff --git a/Assets/Games/Platformer/Ground.physicsMaterial2D b/Assets/Games/Platformer/Ground.physicsMaterial2D new file mode 100644 index 0000000..db40d00 --- /dev/null +++ b/Assets/Games/Platformer/Ground.physicsMaterial2D @@ -0,0 +1,14 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!62 &6200000 +PhysicsMaterial2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Ground + serializedVersion: 2 + friction: 0 + bounciness: 0 + m_FrictionCombine: 1 + m_BounceCombine: 4 diff --git a/Assets/Games/Platformer/Ground.physicsMaterial2D.meta b/Assets/Games/Platformer/Ground.physicsMaterial2D.meta new file mode 100644 index 0000000..eefebcf --- /dev/null +++ b/Assets/Games/Platformer/Ground.physicsMaterial2D.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c29c2a30d0b3d4a9b95031c5dfbd222a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 6200000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Games/Platformer/Platformer Player.prefab b/Assets/Games/Platformer/Platformer Player.prefab index 421163e..907e81b 100644 --- a/Assets/Games/Platformer/Platformer Player.prefab +++ b/Assets/Games/Platformer/Platformer Player.prefab @@ -187,11 +187,13 @@ MonoBehaviour: serializedVersion: 2 m_Bits: 64 walkSpeed: 5 + walkSpeedFactor: 30 + maxSpeed: 5 virtualAxisX: 0 virtualButtonJump: 0 virtualButtonJumpLastFrame: 0 turnaroundMultiplier: 2 - walkSmooth: 0 + walkSmooth: 0.98 secondsToFullSpeed: 0 jumpSpeed: 17 coyoteTime: 0.1 diff --git a/Assets/Games/Platformer/PlatformerPlayerMovement.cs b/Assets/Games/Platformer/PlatformerPlayerMovement.cs index 2041720..c183157 100644 --- a/Assets/Games/Platformer/PlatformerPlayerMovement.cs +++ b/Assets/Games/Platformer/PlatformerPlayerMovement.cs @@ -14,6 +14,8 @@ public class PlayerMovement : MonoBehaviour [Header("Movement")] public float walkSpeed; + public float walkSpeedFactor = 1f; + public float maxSpeed = 5f; public float virtualAxisX; public float virtualButtonJump; public float virtualButtonJumpLastFrame; @@ -65,7 +67,6 @@ public class PlayerMovement : MonoBehaviour HorizontalMovement(); - Land(); } @@ -123,7 +124,18 @@ public class PlayerMovement : MonoBehaviour private void HorizontalMovement() { - body.linearVelocity = new Vector2(virtualAxisX * walkSpeed, body.linearVelocity.y); + //body.linearVelocity = new Vector2(virtualAxisX * walkSpeed, body.linearVelocity.y); + body.AddForce(new Vector2(virtualAxisX * walkSpeed * walkSpeedFactor, 0), ForceMode2D.Force); + + if (Mathf.Abs(body.linearVelocityX) >= maxSpeed) + { + body.linearVelocity = new Vector2(Mathf.Sign(body.linearVelocityX) * maxSpeed, body.linearVelocity.y); + } + + //if (!IsPhysicallyGrounded()) + //{ + body.linearVelocityX *= walkSmooth; + //} if (transform.position == positionLastFrame && (InputSystem.actions.FindAction($"Player {player} Move").ReadValue().x == 0)) { @@ -135,6 +147,12 @@ public class PlayerMovement : MonoBehaviour private void UpdateVirtualAxis() { + virtualButtonJump = InputSystem.actions.FindAction($"Player {player} Action").ReadValue(); + virtualButtonJumpLastFrame = InputSystem.actions.FindAction($"Player {player} Action").WasPressedThisFrame() ? 1 : 0; + + virtualAxisX = InputSystem.actions.FindAction($"Player {player} Move").ReadValue().x; + return; + // From https://discussions.unity.com/t/manually-smooth-input-getaxisraw/225141/4 float basicallyRawAxis = InputSystem.actions.FindAction($"Player {player} Move").ReadValue().x; float sensitivity = 3; @@ -158,9 +176,6 @@ public class PlayerMovement : MonoBehaviour { turnaroundMultiplier = 1; } - - virtualButtonJump = InputSystem.actions.FindAction($"Player {player} Action").ReadValue(); - virtualButtonJumpLastFrame = InputSystem.actions.FindAction($"Player {player} Action").WasPressedThisFrame() ? 1 : 0; } private void OnTriggerEnter2D(Collider2D collision) { diff --git a/Assets/Games/Platformer/Player.physicsMaterial2D b/Assets/Games/Platformer/Player.physicsMaterial2D new file mode 100644 index 0000000..13e03db --- /dev/null +++ b/Assets/Games/Platformer/Player.physicsMaterial2D @@ -0,0 +1,14 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!62 &6200000 +PhysicsMaterial2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Player + serializedVersion: 2 + friction: 0 + bounciness: 0 + m_FrictionCombine: 1 + m_BounceCombine: 4 diff --git a/Assets/Games/Platformer/Player.physicsMaterial2D.meta b/Assets/Games/Platformer/Player.physicsMaterial2D.meta new file mode 100644 index 0000000..daa6cad --- /dev/null +++ b/Assets/Games/Platformer/Player.physicsMaterial2D.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 522e8bb901c31496c91921bd603c0e8b +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 6200000 + userData: + assetBundleName: + assetBundleVariant: From c8bd31c51478e790d6630f859a8bb138d9c01326 Mon Sep 17 00:00:00 2001 From: RochesterX Date: Mon, 13 Jan 2025 16:41:29 -0500 Subject: [PATCH 3/4] Meet bones --- .DS_Store | Bin 0 -> 6148 bytes Assets/.DS_Store | Bin 0 -> 6148 bytes Assets/Games/.DS_Store | Bin 0 -> 6148 bytes Assets/Games/Platformer/Bones.anim | 1549 ++++++++++++++++++ Assets/Games/Platformer/Bones.anim.meta | 8 + Assets/Games/Platformer/Platformer.unity | 759 +++++++++ Assets/Games/Platformer/Root.controller | 72 + Assets/Games/Platformer/Root.controller.meta | 8 + Assets/Games/Platformer/Square.png | Bin 0 -> 388 bytes Assets/Games/Platformer/Square.png.meta | 179 ++ 10 files changed, 2575 insertions(+) create mode 100644 .DS_Store create mode 100644 Assets/.DS_Store create mode 100644 Assets/Games/.DS_Store create mode 100644 Assets/Games/Platformer/Bones.anim create mode 100644 Assets/Games/Platformer/Bones.anim.meta create mode 100644 Assets/Games/Platformer/Root.controller create mode 100644 Assets/Games/Platformer/Root.controller.meta create mode 100755 Assets/Games/Platformer/Square.png create mode 100644 Assets/Games/Platformer/Square.png.meta diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f870d6072699a3aa753300191033b09f6f3d69dc GIT binary patch literal 6148 zcmeHK%}T>S5Z-NTO(;SRDjpZS7OYmJ#Y>F!1&ruHr8XpJFlI}W+CwSis4wKB_&m<+ zZVtiVQN+%a-EVe&b~7Jze;8xjn}>&tIgBw28X`xfM$laAYM5X|uI9*D7A&%9kjS8B zqQ7XuZ*Q|RmccJ#)$jiZrb(RTz1}BpG+P_(P0O-6*1i8E7k)m;=b1N|-Qws<$|NZD zNpKxUi?OqPF4KGxr_oF$#9;&>cQ8Upp+@w#UxyayjUV{$RN3iskUA z*A>V8lhw+$cJ>cWFUQZxODf+qjT{(PvSqM@cTg%7z525>k?AAY%bYTnkQg8ahyh|? z9T_mEfz?^Z;;Ck0fEf6Z0o)%1G(^{6p;2ue(BbtN{VhZk(D5ySC=9v=3yt6b;W`yi zr*iYe;5r@b!o;}-3ynIRakVncV^%I7FI=q-cA>%4;Q4<6f0^1x zel>+g!~iky&lupXkw5aFD08-cD-X|F0qp@A3dR+vfPh}P1i%3Ikv-+qet|l~xdsc3 UI1AcUIv`yH6d}|R1HZt)7h2>?wEzGB literal 0 HcmV?d00001 diff --git a/Assets/.DS_Store b/Assets/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..837018ba6ca03962006fe298e0a30427e2b50aca GIT binary patch literal 6148 zcmeHKPfNov6i?iyEkoEr#bdzh!0ALbyp%feZbc6&v!z3eT{G6s9>$T1{Kr% zO%r~5gIzM8joFATfB#1?iK8^@bUyh;t=`z&vMj4raZu`h za1)L4VQc4HCYc{4qp3=W!V!er-$qF&b63uiFjcvpc38G;4_kZld9N+Hz5b#t=KbSN zTby)H7Yp0kJvcnO8otEiM80VnIqj&BJ>VbC#HXao-k*QtOy zm76C9*XdvvCeATfXw>P9tCe9MvvT=(;c9iT3l+||qmg=IfEZY1pr(f{tp6AA%Tzw{ zS5s(23=jkVi~(LBcmo$UWoqlU?P0AI&>o?oU|fL;2%i$mHoTNM?_xy{Dzjx%i(NCe&K<^}NBu&66hDve zC7C!j4_*Y_d+_p0^70z;Z%G;e5RGAbAD{#P4mvUCVzIy|PCjQj+d~xk8TX)|4_)YB z$@Ui%pm((m;0FrO{vgqbo@HjJw+<}m_mScSA{o}{E!lvI6;>1s;*b3=DjSK$uZf!>a)(C{f}XQ4*Y=R#Ki=l*$m0n3-3i=jR%tV5(=R zXY_jy^ERNGZK)BSX`Y^13>-iXD}xjxD+42tvp@3Xlx~Oh9v) zz$$|*Er2YjE<*zYkZhmz!SKuCd;EY*V^0^ykO=p;=M?!E6a`og&i?&>KD(=vfJW1* vpxukDa(~OJoZNG}>~H>$?+;BGnLu{)XdLGdXf;^W2r|mk)z4*}Q$iB}Ou Date: Mon, 13 Jan 2025 16:46:25 -0500 Subject: [PATCH 4/4] Name Bones --- Assets/Games/Platformer/Platformer.unity | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Games/Platformer/Platformer.unity b/Assets/Games/Platformer/Platformer.unity index 9c48b53..5e39b19 100644 --- a/Assets/Games/Platformer/Platformer.unity +++ b/Assets/Games/Platformer/Platformer.unity @@ -12158,7 +12158,7 @@ GameObject: - component: {fileID: 1355961160} - component: {fileID: 1355961159} m_Layer: 0 - m_Name: Root + m_Name: Bones m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0