فهرست منبع

增加被击飞时的减速比率参数

wulifu 1 سال پیش
والد
کامیت
0d09e953d4

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

@@ -325,10 +325,13 @@ public class Demonic : MoveCharacter
                     ChangeState(CharacterState.Idle);
                     break;
                 }
-                if (!foot.TrigGround && !canFly)
+                if (!foot.TrigGround)
                 {
                     rb.velocity += Vector3.up * extraFallGravity * Time.deltaTime;
                 }
+                Vector3 vel = rb.velocity;
+                vel.x = vel.x * (1 - decelerationRatio * Time.deltaTime);
+                rb.velocity = vel;
                 break;
             case CharacterState.Attack:
                 if (attackTime <= 0)

+ 3 - 0
ActionTowerDefense/Assets/Scripts/Enemy.cs

@@ -274,6 +274,9 @@ public class Enemy : MoveCharacter
                 {
                     rb.velocity += Vector3.up * extraFallGravity * Time.deltaTime;
                 }
+                Vector3 vel = rb.velocity;
+                vel.x = vel.x * (1 - decelerationRatio * Time.deltaTime);
+                rb.velocity = vel;
                 break;
             case CharacterState.Attack:
                 if (attackTime <= 0)

+ 1 - 0
ActionTowerDefense/Assets/Scripts/MoveCharacter.cs

@@ -16,6 +16,7 @@ public class MoveCharacter : Character
     public float weakTime;
     public float totalWeakTime;
     public float weakUpSpeed = 10f;
+    public float decelerationRatio = 1f;
 
     public override void BeHit(int damage, Vector3 force, bool changeHurt, float hurtTime, float repelValue)
     {

+ 7 - 0
ActionTowerDefense/Assets/Scripts/PlayerController.cs

@@ -522,6 +522,13 @@ public class PlayerController : MoveCharacter
                         break;
                     }
                 }
+                if (!foot.TrigGround)
+                {
+                    rb.velocity += Vector3.up * extraFallGravity * Time.deltaTime;
+                }
+                Vector3 vel = rb.velocity;
+                vel.x = vel.x * (1 - decelerationRatio * Time.deltaTime);
+                rb.velocity = vel;
                 CachedPlayerInput();
                 break;
             case CharacterState.Attack: