From ed42b67e0f518f6315370b29beebd49e47350450 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Sun, 29 Oct 2023 21:22:13 +0800 Subject: *misc --- "Doc/ROUNDS\345\210\206\346\236\220.xlsx" | Bin 10740153 -> 11580685 bytes ROUNDS/.vs/ROUNDS/v17/.suo | Bin 214016 -> 214528 bytes ROUNDS/_Player/LegRaycasters.cs | 4 +- ROUNDS/_Player/PlayerCollision.cs | 79 +++++++++++---------- ROUNDS/_Player/PlayerMovement.cs | 12 ++-- .../bin/Debug/netstandard2.1/Assembly-CSharp.dll | Bin 909312 -> 907776 bytes .../bin/Debug/netstandard2.1/Assembly-CSharp.pdb | Bin 487088 -> 486436 bytes .../obj/Debug/netstandard2.1/Assembly-CSharp.dll | Bin 909312 -> 907776 bytes .../obj/Debug/netstandard2.1/Assembly-CSharp.pdb | Bin 487088 -> 486436 bytes 9 files changed, 48 insertions(+), 47 deletions(-) diff --git "a/Doc/ROUNDS\345\210\206\346\236\220.xlsx" "b/Doc/ROUNDS\345\210\206\346\236\220.xlsx" index beb0760..bed2132 100644 Binary files "a/Doc/ROUNDS\345\210\206\346\236\220.xlsx" and "b/Doc/ROUNDS\345\210\206\346\236\220.xlsx" differ diff --git a/ROUNDS/.vs/ROUNDS/v17/.suo b/ROUNDS/.vs/ROUNDS/v17/.suo index 8d8f70d..933d54b 100644 Binary files a/ROUNDS/.vs/ROUNDS/v17/.suo and b/ROUNDS/.vs/ROUNDS/v17/.suo differ diff --git a/ROUNDS/_Player/LegRaycasters.cs b/ROUNDS/_Player/LegRaycasters.cs index fa3066e..db65cf1 100644 --- a/ROUNDS/_Player/LegRaycasters.cs +++ b/ROUNDS/_Player/LegRaycasters.cs @@ -37,7 +37,7 @@ public class LegRaycasters : MonoBehaviour //! 重要,这个代码会让角色站在地面上,不会陷下去(属于模拟跑步时一上一下的附加效果,主要还是要看playercollision的fixedupdate) // 和PlayerCollision的FixedUpdate代码配合 - // 关键代码是TouchGround,addforce不关键 + // 关键代码是TouchGround,addforce不关键,站在地面上时让gravity为0 private void FixedUpdate() { totalStepTime = 0f; @@ -67,7 +67,7 @@ public class LegRaycasters : MonoBehaviour { if (!(data.sinceJump < 0.2f) && !(Vector3.Angle(Vector3.up, hit.normal) > 70f)) { - // touch ground 很重要 + // touch ground 很重要,影响着地后的gravity为0 data.TouchGround(hit.point, hit.normal, hit.rigidbody); // 施加向上的力 diff --git a/ROUNDS/_Player/PlayerCollision.cs b/ROUNDS/_Player/PlayerCollision.cs index 612f8e0..c6f2750 100644 --- a/ROUNDS/_Player/PlayerCollision.cs +++ b/ROUNDS/_Player/PlayerCollision.cs @@ -52,38 +52,38 @@ public class PlayerCollision : MonoBehaviour private void FixedUpdate() { - #region 检测墙,和地面无关(好像也有关) - if (checkForGoThroughWall && ignoreWallFor <= 0) - { - RaycastHit2D raycastHit2D = default(RaycastHit2D); - RaycastHit2D[] array = Physics2D.RaycastAll(lastPos, (Vector2)base.transform.position - lastPos, Vector2.Distance(base.transform.position, lastPos), mask); - for (int i = 0; i < array.Length; i++) - { - if (!(array[i].transform.root == base.transform.root)) - { - Debug.DrawLine(lastPos, array[i].point, Color.green, 1f); - if (!(Vector2.Angle(array[i].normal, (Vector2)base.transform.position - lastPos) < 90f) && (!raycastHit2D.transform || array[i].distance < raycastHit2D.distance)) - { - raycastHit2D = array[i]; - } - } - } - if ((bool)raycastHit2D) - { - base.transform.position = raycastHit2D.point + raycastHit2D.normal * 0.5f; - if (data.healthHandler.flyingFor > 0f) - { - DoBounce(raycastHit2D); - } - } - } - #endregion + #region 检测墙,和地面无关(好像也有关) + if (checkForGoThroughWall && ignoreWallFor <= 0) + { + RaycastHit2D raycastHit2D = default(RaycastHit2D); + RaycastHit2D[] array = Physics2D.RaycastAll(lastPos, (Vector2)base.transform.position - lastPos, Vector2.Distance(base.transform.position, lastPos), mask); + for (int i = 0; i < array.Length; i++) + { + if (!(array[i].transform.root == base.transform.root)) + { + Debug.DrawLine(lastPos, array[i].point, Color.green, 1f); + if (!(Vector2.Angle(array[i].normal, (Vector2)base.transform.position - lastPos) < 90f) && (!raycastHit2D.transform || array[i].distance < raycastHit2D.distance)) + { + raycastHit2D = array[i]; + } + } + } + if ((bool)raycastHit2D) + { + base.transform.position = raycastHit2D.point + raycastHit2D.normal * 0.5f; + if (data.healthHandler.flyingFor > 0f) + { + DoBounce(raycastHit2D); + } + } + } + #endregion - #region 碰撞检测 - ignoreWallFor--; + #region 碰撞检测 + ignoreWallFor--; lastPos = base.transform.position; float realRadius = cirCol.radius * base.transform.localScale.x; - float innerRadius = cirCol.radius * base.transform.localScale.x * 0.75f; + float innerRadius = cirCol.radius * base.transform.localScale.x * 0.75f; // // 以circlecollider的位置和大小为参考做碰撞检测 RaycastHit2D[] array2 = Physics2D.CircleCastAll(lastPos, realRadius, (Vector2)base.transform.position - lastPos, Vector2.Distance(base.transform.position, lastPos), mask); for (int j = 0; j < array2.Length; j++) @@ -107,18 +107,19 @@ public class PlayerCollision : MonoBehaviour component.Push(data); } - if (vel.simulated || !vel.isKinematic) + //! 把角色往返方向推 + if (vel.simulated || !vel.isKinematic) // true { - vel.transform.position += (Vector3)dirFromHitpoint * innerPushAmount; // 把角色往返方向推 - if (Mathf.Abs(dirFromHitpoint.y) < 0.45f && Mathf.Abs(data.input.direction.x) > 0.1f && Vector3.Angle(data.input.direction, dirFromHitpoint) > 90f) - { - data.TouchWall(dirFromHitpoint, point); - } - vel.velocity += dirFromHitpoint * realPushAmount * 10f * TimeHandler.timeScale; - vel.velocity -= vel.velocity * realPushAmount * 1f * TimeHandler.timeScale; - } + vel.transform.position += (Vector3)dirFromHitpoint * innerPushAmount; // 不是很重要,可以注释掉 + if (Mathf.Abs(dirFromHitpoint.y) < 0.45f && Mathf.Abs(data.input.direction.x) > 0.1f && Vector3.Angle(data.input.direction, dirFromHitpoint) > 90f) + { + data.TouchWall(dirFromHitpoint, point); + } + vel.velocity += dirFromHitpoint * realPushAmount * 10f * TimeHandler.timeScale; + vel.velocity -= vel.velocity * realPushAmount * 1f * TimeHandler.timeScale; + } - Player componentInParent = array2[j].transform.GetComponentInParent(); + Player componentInParent = array2[j].transform.GetComponentInParent(); if (componentInParent != null && collideWithPlayerAction != null) { collideWithPlayerAction(point, realPushAmount * dirFromHitpoint, componentInParent); diff --git a/ROUNDS/_Player/PlayerMovement.cs b/ROUNDS/_Player/PlayerMovement.cs index 39dc27e..c4753c6 100644 --- a/ROUNDS/_Player/PlayerMovement.cs +++ b/ROUNDS/_Player/PlayerMovement.cs @@ -39,14 +39,14 @@ public class PlayerMovement : MonoBehaviour _ = data.input.direction.x; _ = 0f; } - data.playerVel.velocity = velocity; + data.playerVel.velocity = velocity;//不重要 } - // 和速度相反的空气阻力 - data.playerVel.velocity -= data.playerVel.velocity * TimeHandler.timeScale * 0.01f * 0.1f * extraDrag * multiplier; - data.playerVel.angularVelocity -= data.playerVel.angularVelocity * TimeHandler.timeScale * 0.01f * 0.1f * extraAngularDrag * multiplier; - } + // 和速度相反的空气阻力 + data.playerVel.velocity -= data.playerVel.velocity * TimeHandler.timeScale * 0.01f * 0.1f * extraDrag * multiplier; + data.playerVel.angularVelocity -= data.playerVel.angularVelocity * TimeHandler.timeScale * 0.01f * 0.1f * extraAngularDrag * multiplier; + } - private void Update() + private void Update() { } diff --git a/ROUNDS/bin/Debug/netstandard2.1/Assembly-CSharp.dll b/ROUNDS/bin/Debug/netstandard2.1/Assembly-CSharp.dll index d09f77a..8ee191b 100644 Binary files a/ROUNDS/bin/Debug/netstandard2.1/Assembly-CSharp.dll and b/ROUNDS/bin/Debug/netstandard2.1/Assembly-CSharp.dll differ diff --git a/ROUNDS/bin/Debug/netstandard2.1/Assembly-CSharp.pdb b/ROUNDS/bin/Debug/netstandard2.1/Assembly-CSharp.pdb index 867765c..b748500 100644 Binary files a/ROUNDS/bin/Debug/netstandard2.1/Assembly-CSharp.pdb and b/ROUNDS/bin/Debug/netstandard2.1/Assembly-CSharp.pdb differ diff --git a/ROUNDS/obj/Debug/netstandard2.1/Assembly-CSharp.dll b/ROUNDS/obj/Debug/netstandard2.1/Assembly-CSharp.dll index d09f77a..8ee191b 100644 Binary files a/ROUNDS/obj/Debug/netstandard2.1/Assembly-CSharp.dll and b/ROUNDS/obj/Debug/netstandard2.1/Assembly-CSharp.dll differ diff --git a/ROUNDS/obj/Debug/netstandard2.1/Assembly-CSharp.pdb b/ROUNDS/obj/Debug/netstandard2.1/Assembly-CSharp.pdb index 867765c..b748500 100644 Binary files a/ROUNDS/obj/Debug/netstandard2.1/Assembly-CSharp.pdb and b/ROUNDS/obj/Debug/netstandard2.1/Assembly-CSharp.pdb differ -- cgit v1.1-26-g67d0