Browse Source

修桥修桥(击飞不穿桥)

WGL 4 tháng trước cách đây
mục cha
commit
511c2e6f19

+ 10 - 1
ActionTowerDefense/Assets/Scripts/Characters/AttributeStatus.cs

@@ -271,9 +271,13 @@ public class AttributeStatus : MonoBehaviour
                         break;
                     case 0:
                         Vector3 vel = rb.velocity;
-                        if (isFly && foot.TrigGround && vel.y <= 0.01f)
+                        if (isFly && foot.TrigGround)
                         {
                             vel = Vector3.zero;
+                            if (!foot.haveGravity)
+                            {
+                                transform.position = new Vector3(transform.position.x, character.platformPosY, transform.position.z);
+                            }
                             character.ani.Play("weak", 0, 0);
                             hitState = 1;
                             if (haveLandingDamage)
@@ -295,11 +299,14 @@ public class AttributeStatus : MonoBehaviour
                         {
                             character.isAdjustHeight = 1;
                             character.nowCanFly = character.canFly;
+
                             OutSpecialState();
                         }
                         else
                         {
                             rb.velocity = Vector3.zero;
+                            rb.useGravity = false;
+                            character.transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y,character.platformRotZ); ;
                             attributeTime -= Time.deltaTime;
                         }
                         break;
@@ -410,6 +417,7 @@ public class AttributeStatus : MonoBehaviour
         rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
         rb.velocity = Vector3.zero;
         rb.AddForce(vec3 * blowUp.force * (1 - resistances.BlowUp), ForceMode.Impulse);
+        rb.transform.rotation = Quaternion.Euler(0, 0, 0);
         haveLandingDamage = blowUp.haveLandingDamage;
         landingDamage = blowUp.landingDamage;
         hitState = 0;
@@ -440,6 +448,7 @@ public class AttributeStatus : MonoBehaviour
         rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
         rb.velocity = Vector3.zero;
         rb.AddForce(vec3 * shotDown.force * (1 - resistances.ShotDown), ForceMode.Impulse);
+        rb.transform.rotation = Quaternion.Euler(0, 0, 0);
         character.ani.Play("hitted", 0, 0);
         haveLandingDamage = shotDown.haveLandingDamage;
         landingDamage = shotDown.landingDamage;

+ 14 - 2
ActionTowerDefense/Assets/Scripts/Characters/Demonic.cs

@@ -274,6 +274,7 @@ public class Demonic : MoveCharacter
         Vector3 leftDir = GetMoveDir();
         bool isAttack = GetAttack();
         Vector3 velocity = rb.velocity;
+        Quaternion targetQt = Quaternion.Euler(Vector3.zero);
         switch (state)
         {
             case CharacterState.Idle:
@@ -311,7 +312,6 @@ public class Demonic : MoveCharacter
                     }
                     velocity.x = velocityAddition;
                     velocity.y = 0;
-                    Quaternion targetQt = Quaternion.Euler(Vector3.zero);
                     if (!foot.haveGravity)
                     {
                         transform.position = new Vector3(transform.position.x, platformPosY, transform.position.z);
@@ -380,7 +380,6 @@ public class Demonic : MoveCharacter
                         }
                     }
                     velocity.y = 0;
-                    Quaternion targetQt = Quaternion.Euler(Vector3.zero);
                     if (!foot.haveGravity)
                     {
                         transform.position = new Vector3(transform.position.x, platformPosY, transform.position.z);
@@ -519,6 +518,19 @@ public class Demonic : MoveCharacter
                     }
                     break;
                 }
+                if (!foot.haveGravity)
+                {
+                    targetQt = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, platformRotZ);
+                }
+                if (RotLerpTime < 1)
+                {
+                    RotLerpTime += RotLerpSpeed * Time.deltaTime;
+                    transform.rotation = Quaternion.Lerp(transform.rotation, targetQt, RotLerpTime);
+                }
+                else
+                {
+                    transform.rotation = targetQt;
+                }
                 rb.velocity = new Vector3(velocityAddition, rb.velocity.y, rb.velocity.z);
                 break;
             case CharacterState.Die:

+ 14 - 2
ActionTowerDefense/Assets/Scripts/Characters/Enemy.cs

@@ -215,6 +215,7 @@ public class Enemy : MoveCharacter
         Vector3 leftDir = GetMoveDir();
         bool isAttack = GetAttack();
         Vector3 velocity = rb.velocity;
+        Quaternion targetQt = Quaternion.Euler(Vector3.zero);
         switch (state)
         {
             case CharacterState.Idle:
@@ -251,7 +252,6 @@ public class Enemy : MoveCharacter
                         break;
                     }
                     velocity.y = 0;
-                    Quaternion targetQt = Quaternion.Euler(Vector3.zero);
                     if (!foot.haveGravity)
                     {
                         transform.position = new Vector3(transform.position.x, platformPosY, transform.position.z);
@@ -318,7 +318,6 @@ public class Enemy : MoveCharacter
                         }
                     }
                     velocity.y = 0;
-                    Quaternion targetQt = Quaternion.Euler(Vector3.zero);
                     if (!foot.haveGravity)
                     {
                         transform.position = new Vector3(transform.position.x, platformPosY, transform.position.z);
@@ -450,6 +449,19 @@ public class Enemy : MoveCharacter
                     ChangeState(CharacterState.Idle);
                     break;
                 }
+                if (!foot.haveGravity)
+                {
+                    targetQt = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, platformRotZ);
+                }
+                if (RotLerpTime < 1)
+                {
+                    RotLerpTime += RotLerpSpeed * Time.deltaTime;
+                    transform.rotation = Quaternion.Lerp(transform.rotation, targetQt, RotLerpTime);
+                }
+                else
+                {
+                    transform.rotation = targetQt;
+                }
                 break;
             case CharacterState.Die:
                 if (dieKeepTime <= 0)