Переглянути джерело

浮空地块,胖子可以踩

LAPTOP-OM1V99U2\永远de小亡灵 1 рік тому
батько
коміт
4d2585458a

+ 6 - 4
ActionTowerDefense/Assets/Resources/Prefab/Demonic_Giant.prefab

@@ -170,7 +170,7 @@ GameObject:
   - component: {fileID: 3410108659653096532}
   - component: {fileID: 3051270209667538022}
   - component: {fileID: 6236498711544088984}
-  m_Layer: 3
+  m_Layer: 13
   m_Name: ground
   m_TagString: Plane
   m_Icon: {fileID: 0}
@@ -186,7 +186,7 @@ Transform:
   m_GameObject: {fileID: 2605737647177614769}
   m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
   m_LocalPosition: {x: 0.3, y: 4.11, z: 0}
-  m_LocalScale: {x: 5, y: 0.099999994, z: 1}
+  m_LocalScale: {x: 5, y: 0.1, z: 1}
   m_ConstrainProportionsScale: 0
   m_Children: []
   m_Father: {fileID: 901824162977467732}
@@ -253,8 +253,8 @@ BoxCollider:
   m_IsTrigger: 0
   m_Enabled: 1
   serializedVersion: 2
-  m_Size: {x: 1, y: 1, z: 20}
-  m_Center: {x: 0, y: 0, z: 0}
+  m_Size: {x: 1, y: 10, z: 20}
+  m_Center: {x: 0, y: -5, z: 0}
 --- !u!1 &4480734502875862885
 GameObject:
   m_ObjectHideFlags: 0
@@ -475,6 +475,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: c42213c575288a148b692aad7ab56bab, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  rb: {fileID: 0}
+  haveGravity: 1
   trigGroundList: []
 --- !u!1 &5440846222648032759
 GameObject:

+ 6 - 6
ActionTowerDefense/Assets/Scenes/SampleScene.unity

@@ -16824,7 +16824,7 @@ GameObject:
   - component: {fileID: 1497593549}
   - component: {fileID: 1497593548}
   - component: {fileID: 1497593547}
-  m_Layer: 3
+  m_Layer: 13
   m_Name: Cube (5)
   m_TagString: Plane
   m_Icon: {fileID: 0}
@@ -16857,8 +16857,8 @@ BoxCollider:
   m_IsTrigger: 0
   m_Enabled: 1
   serializedVersion: 2
-  m_Size: {x: 1, y: 1, z: 20}
-  m_Center: {x: 0, y: 0, z: 0}
+  m_Size: {x: 1, y: 10, z: 20}
+  m_Center: {x: 0, y: -5, z: 0}
 --- !u!23 &1497593548
 MeshRenderer:
   m_ObjectHideFlags: 0
@@ -27020,7 +27020,7 @@ GameObject:
   - component: {fileID: 2045679348}
   - component: {fileID: 2045679347}
   - component: {fileID: 2045679346}
-  m_Layer: 3
+  m_Layer: 13
   m_Name: Cube (4)
   m_TagString: Plane
   m_Icon: {fileID: 0}
@@ -27053,8 +27053,8 @@ BoxCollider:
   m_IsTrigger: 0
   m_Enabled: 1
   serializedVersion: 2
-  m_Size: {x: 1, y: 1, z: 20}
-  m_Center: {x: 0, y: 0, z: 0}
+  m_Size: {x: 1, y: 10, z: 20}
+  m_Center: {x: 0, y: -5, z: 0}
 --- !u!23 &2045679347
 MeshRenderer:
   m_ObjectHideFlags: 0

+ 34 - 1
ActionTowerDefense/Assets/Scripts/Foot.cs

@@ -4,6 +4,8 @@ using UnityEngine;
 
 public class Foot : MonoBehaviour
 {
+    public Rigidbody rb;
+    public bool haveGravity = true;
     public bool TrigGround
     {
         get
@@ -16,9 +18,40 @@ public class Foot : MonoBehaviour
 
     private void Awake()
     {
-        
+        rb = GetComponentInParent<Rigidbody>();
     }
+    private void Update()
+    {
+        if (trigGroundList.Count == 0)
+        {
+            if (!haveGravity)
+            {
+                rb.useGravity = true;
+                haveGravity = true;
+            }
+        }
+        else
+        {
+            if (haveGravity && rb.velocity.y<0)
+            {
+                foreach (GameObject i in trigGroundList)
+                {
+                    if (i.layer == 13)
+                    {
+                        rb.useGravity = false;
+                        rb.velocity = new Vector3(rb.velocity.x, 0, rb.velocity.z);
+                        haveGravity = false;
+                        rb.transform.position = new Vector3
+                            (rb.transform.position.x, i.transform.position.y, rb.transform.position.z);
+                        break;
+                    }
+                }
+            }
+
+        }
 
+        
+    }
     private void FixedUpdate()
     {
         for (int i = 0; i < trigGroundList.Count; i++)

+ 1 - 1
ActionTowerDefense/ProjectSettings/DynamicsManager.asset

@@ -18,7 +18,7 @@ PhysicsManager:
   m_ClothInterCollisionDistance: 0.1
   m_ClothInterCollisionStiffness: 0.2
   m_ContactsGeneration: 1
-  m_LayerCollisionMatrix: ff87ffffff87ffffff87fffffff7ffffff87ffffff87ffff3f80ffff3f80ffff3f80ffff3f80ffff3f80ffff0090ffff0888ffff08c0ffff08a0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+  m_LayerCollisionMatrix: ffa7ffffffa7ffffffa7fffffff7ffffffa7ffffffa7ffff3f80ffff3fa0ffff3fa0ffff3fa0ffff3fa0ffff0090ffff08a8ffffbff7ffff08a0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
   m_AutoSimulation: 1
   m_AutoSyncTransforms: 0
   m_ReuseCollisionCallbacks: 1

+ 1 - 1
ActionTowerDefense/ProjectSettings/TagManager.asset

@@ -24,7 +24,7 @@ TagManager:
   - EnemyTower
   - Soul
   - Attackless
-  - 
+  - Platform
   - 
   - 
   -