Kaynağa Gözat

隐身状态下自由飞行

LAPTOP-OM1V99U2\永远de小亡灵 1 yıl önce
ebeveyn
işleme
2d54973af4

+ 0 - 31
ActionTowerDefense/Assets/Resources/Prefab/FX/Invisible_effc.prefab

@@ -14640,8 +14640,6 @@ GameObject:
   serializedVersion: 6
   m_Component:
   - component: {fileID: 7473170563405908937}
-  - component: {fileID: 7414042625370929500}
-  - component: {fileID: 8541051486027365006}
   m_Layer: 0
   m_Name: Invisible_effc
   m_TagString: Untagged
@@ -14665,35 +14663,6 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
---- !u!65 &7414042625370929500
-BoxCollider:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 7473170563405908938}
-  m_Material: {fileID: 0}
-  m_IsTrigger: 1
-  m_Enabled: 1
-  serializedVersion: 2
-  m_Size: {x: 0.5, y: 0.5, z: 1}
-  m_Center: {x: 0, y: 0, z: 0}
---- !u!54 &8541051486027365006
-Rigidbody:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 7473170563405908938}
-  serializedVersion: 2
-  m_Mass: 1
-  m_Drag: 0
-  m_AngularDrag: 0.05
-  m_UseGravity: 0
-  m_IsKinematic: 0
-  m_Interpolate: 0
-  m_Constraints: 56
-  m_CollisionDetection: 0
 --- !u!1 &8530665648963853532
 GameObject:
   m_ObjectHideFlags: 0

+ 21 - 5
ActionTowerDefense/Assets/Resources/Prefab/Spirits_Invisible.prefab

@@ -129,6 +129,7 @@ GameObject:
   - component: {fileID: 6801157681521274923}
   - component: {fileID: 2437299196472462353}
   - component: {fileID: 2437299196472462355}
+  - component: {fileID: 8394241662262430318}
   m_Layer: 7
   m_Name: Spirits_Invisible
   m_TagString: Demonic
@@ -144,7 +145,7 @@ Transform:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 2437299196472462361}
   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
-  m_LocalPosition: {x: 8.01, y: 0, z: 0}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children:
@@ -176,6 +177,8 @@ MonoBehaviour:
   beSearchTrigger: {fileID: 0}
   UI: {fileID: 0}
   playerController: {fileID: 0}
+  rb: {fileID: 2437299196472462355}
+  speed: 20
 --- !u!114 &2437299196472462353
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -183,7 +186,7 @@ MonoBehaviour:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 2437299196472462361}
-  m_Enabled: 1
+  m_Enabled: 0
   m_EditorHideFlags: 0
   m_Script: {fileID: 11500000, guid: c1bedfb340186164dbac1499b49b879e, type: 3}
   m_Name: 
@@ -273,14 +276,27 @@ Rigidbody:
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 2437299196472462361}
   serializedVersion: 2
-  m_Mass: 20
-  m_Drag: 0.1
+  m_Mass: 1
+  m_Drag: 0
   m_AngularDrag: 0.05
   m_UseGravity: 0
   m_IsKinematic: 0
   m_Interpolate: 0
-  m_Constraints: 126
+  m_Constraints: 120
   m_CollisionDetection: 0
+--- !u!65 &8394241662262430318
+BoxCollider:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2437299196472462361}
+  m_Material: {fileID: 0}
+  m_IsTrigger: 0
+  m_Enabled: 1
+  serializedVersion: 2
+  m_Size: {x: 3, y: 3, z: 3}
+  m_Center: {x: 0, y: 0, z: 0}
 --- !u!1 &2437299196663985757
 GameObject:
   m_ObjectHideFlags: 0

+ 20 - 4
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Invisible.cs

@@ -21,7 +21,9 @@ public class Spirits_Invisible : MonoBehaviour
     public GameObject UI;
     [HideInInspector]
     public PlayerController playerController;
-    private void Awake()
+    public Rigidbody rb;
+    public float speed;
+    private void Start()
     {
         
         player = PlayersInput.instance[demonic.playerID].gameObject;
@@ -34,14 +36,22 @@ public class Spirits_Invisible : MonoBehaviour
         UI.SetActive(false);
         beSearchTrigger.SetActive(false);
         spine.SetActive(false);
-
+        transform.position = player.transform.position + Vector3.up ;
+        playerController.rb.useGravity = false;
+        playerController.rb.constraints = RigidbodyConstraints.FreezeAll;
     }
     private void Update()
     {
-        if(time >0.97f && (playerController.isClickBtnEast || playerController.isClickBtnWest
+        //transform.position = body.transform.position + Vector3.up;
+        rb.velocity = playerController.leftDir * speed;
+        player.transform.position = transform.position + Vector3.down * 1.5f;
+        if (time >0.97f && (playerController.isClickBtnEast || playerController.isClickBtnWest
             ||playerController.isClickBtnSouth||playerController.isSpiritSummon
             ||playerController.isSpiritSummon1||playerController.isSpiritSummon2))
         {
+            playerController.rb.useGravity = true;
+            playerController.rb.constraints = RigidbodyConstraints.FreezePositionZ 
+                |RigidbodyConstraints.FreezeRotation;
             playerController.isInvisible = false;
             UI.SetActive(true);
             beSearchTrigger.SetActive(true);
@@ -51,6 +61,9 @@ public class Spirits_Invisible : MonoBehaviour
         }
         if(time > 0.97f && playerController.isSpiritSummon3)
         {
+            playerController.rb.useGravity = true;
+            playerController.rb.constraints = RigidbodyConstraints.FreezePositionZ
+                | RigidbodyConstraints.FreezeRotation;
             UI.SetActive(true);
             beSearchTrigger.SetActive(true);
             spine.SetActive(true);
@@ -58,9 +71,12 @@ public class Spirits_Invisible : MonoBehaviour
             gameObject.SetActive(false);
         }
         time += Time.deltaTime;
-        transform.position = body.transform.position + Vector3.up;
+        
         if (time >= duration)
         {
+            playerController.rb.useGravity = true;
+            playerController.rb.constraints = RigidbodyConstraints.FreezePositionZ
+                | RigidbodyConstraints.FreezeRotation;
             playerController.isInvisible = false;
             UI.SetActive(true);
             beSearchTrigger.SetActive(true);