Pārlūkot izejas kodu

胖子能站在胖子上,修复往前走不会掉下去的bug

LAPTOP-OM1V99U2\永远de小亡灵 1 gadu atpakaļ
vecāks
revīzija
8ac649ce6d

+ 2 - 1
ActionTowerDefense/Assets/Resources/Prefab/Demonic_Giant.prefab

@@ -270,6 +270,7 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   rb: {fileID: 5440846222648032765}
   feet: []
+  edgeDistance: 2.5
 --- !u!1 &4480734502875862885
 GameObject:
   m_ObjectHideFlags: 0
@@ -664,7 +665,7 @@ MonoBehaviour:
   soulStartSpeed: 1
   isInvisible: 0
   invisibleTime: 0
-  velocityAddition: {x: 0, y: 0, z: 0}
+  velocityAddition: 0
   easyToGetHit: 0.2
   player: {fileID: 0}
   id: 0

+ 5 - 4
ActionTowerDefense/Assets/Scripts/Demonic.cs

@@ -294,7 +294,7 @@ public class Demonic : MoveCharacter
                     break;
                 }
                 AdjustHeight();
-                //rb.velocity = Vector3.zero;
+                rb.velocity = Vector3.right * velocityAddition;
                 break;
             case CharacterState.Run:
                 if (isAttack)
@@ -323,7 +323,7 @@ public class Demonic : MoveCharacter
                 if (leftDir.x > 0.3f)
                 {
                     //rb.velocity += Vector3.right * moveAcc * Time.deltaTime;
-                    rb.velocity = Vector3.right * moveSpeed;
+                    rb.velocity = Vector3.right * (moveSpeed + velocityAddition);
                     //if (rb.velocity.x > maxMoveSpeed)
                     //{
                     //    rb.velocity = new Vector3(maxMoveSpeed, rb.velocity.y, rb.velocity.z);
@@ -336,7 +336,7 @@ public class Demonic : MoveCharacter
                 else if (leftDir.x < -0.3f)
                 {
                     //rb.velocity -= Vector3.right * moveAcc * Time.deltaTime;
-                    rb.velocity = Vector3.left * moveSpeed;
+                    rb.velocity = Vector3.right *( -moveSpeed + velocityAddition);
                     //if (rb.velocity.x < -maxMoveSpeed)
                     //{
                     //    rb.velocity = new Vector3(-maxMoveSpeed, rb.velocity.y, rb.velocity.z);
@@ -485,11 +485,11 @@ public class Demonic : MoveCharacter
                     ChangeState(CharacterState.Idle);
                     break;
                 }
+                rb.velocity = new Vector3(velocityAddition,rb.velocity.y,rb.velocity.z);
                 break;
             case CharacterState.Die:
                 if (dieKeepTime <= 0)
                 {
-                    print("Die:" + gameObject.name);
                     if (!isSpirit)
                     {
                         Corpse.allCorpsesNum += 1;
@@ -505,6 +505,7 @@ public class Demonic : MoveCharacter
                     ChangeState(CharacterState.Idle);
                     break;
                 }
+                rb.velocity = Vector3.right * velocityAddition;
                 break;
             default:
                 break;

+ 8 - 2
ActionTowerDefense/Assets/Scripts/Platform.cs

@@ -6,13 +6,18 @@ public class Platform : MonoBehaviour
 {
     public Rigidbody rb;
     public List<Foot> feet = new List<Foot>();
+    public float edgeDistance;
 
     private void OnTriggerEnter(Collider other)
     {
         
         Foot foot = other.GetComponent<Foot>();
-        if (foot != null)
+        if (foot != null && foot.gameObject.layer != 8)
         {
+            if (Mathf.Abs(foot.transform.position.x - transform.position.x) > edgeDistance)
+            {
+                return;
+            }
             foot.trigGroundList.Add(gameObject);
             feet.Add(foot);
         }
@@ -20,8 +25,9 @@ public class Platform : MonoBehaviour
     private void OnTriggerExit(Collider other)
     {
         Foot foot = other.GetComponent<Foot>();
-        if(foot != null)
+        if(foot != null && foot.gameObject.layer != 8)
         {
+
             if(foot.trigGroundList.Exists(i =>i == gameObject))
             {
                 foot.trigGroundList.Remove(gameObject);