Sfoglia il codice sorgente

人物方向输入优化:召唤的时候缓存一下按键,召唤结束响应

LAPTOP-OM1V99U2\永远de小亡灵 1 anno fa
parent
commit
80fa49d30d
1 ha cambiato i file con 18 aggiunte e 1 eliminazioni
  1. 18 1
      ActionTowerDefense/Assets/Scripts/PlayerController.cs

+ 18 - 1
ActionTowerDefense/Assets/Scripts/PlayerController.cs

@@ -125,6 +125,7 @@ public class PlayerController : MoveCharacter
     public float cacheSummonTime; //无法召唤时按下召唤键不会召唤,手感不好,缓存几帧,在这几帧内落地会立即召唤;
     [HideInInspector]
     public int cacheSummonId;
+    public float cacheDir;  //召唤的时候按左右召唤结束不会响应手感不好,缓存一下,召唤后摇期间有左右响应的话会转向
 
     [Header("召唤使魔")]
     public List<GameObject> demonicPrefabs;
@@ -1152,7 +1153,10 @@ public class PlayerController : MoveCharacter
                     }
                 }
                 rb.velocity = Vector3.right * velocityAddition;
-               
+                if (leftDir.x > 0.3f || leftDir.x < -0.3f)
+                {
+                    cacheDir = leftDir.x;
+                }
                 break;
             case CharacterState.Rush:
                 if (rushTime <= 0)
@@ -1461,6 +1465,18 @@ public class PlayerController : MoveCharacter
                 break;
             case CharacterState.Summon:
                 rb.isKinematic = false;
+                if(cacheDir != 0)
+                {
+                    if (cacheDir > 0.3f && bodyTrans.localScale.x > 0)
+                    {
+                        Turn();
+                    }
+                    else if (cacheDir < -0.3f && bodyTrans.localScale.x < 0)
+                    {
+                        Turn();
+                    }
+                    cacheDir = 0;
+                }
                 break;
             case CharacterState.Transfiguration:
                 rb.isKinematic = false;
@@ -1539,6 +1555,7 @@ public class PlayerController : MoveCharacter
                 ani.Play("summon", 0, 0);
                 velocity = Vector3.right * velocityAddition;
                 rb.isKinematic = true;
+                cacheDir = 0;
                 break;
             case CharacterState.Transfiguration:
                 aniCollider.Play("Transfiguration", 0, 0);