Browse Source

Make apples kinematic

Alex Peterson 2 years ago
parent
commit
f38e40bb4c

+ 10 - 10
Project/Levels/MainNoVegMerged/MainNoVegMerged.prefab

@@ -733,7 +733,7 @@
                     "Controller": {
                         "Configuration": {
                             "Field of View": 55.0,
-                            "EditorEntityId": 11787391379556193736
+                            "EditorEntityId": 9401405681626518820
                         }
                     }
                 },
@@ -1023,7 +1023,7 @@
                                 },
                                 "assetHint": "reflectionprobes/refprobmain__c4ee43e2-3ffe-4955-9dee-679ca04c2a53__iblspecularcm256.dds.streamingimage"
                             },
-                            "EntityId": 16795520573185795105
+                            "EntityId": 4255235585367832113
                         }
                     },
                     "useBakedCubemap": false,
@@ -1360,7 +1360,7 @@
                     "$type": "EditorImageGradientComponent",
                     "Id": 6913475367130875979,
                     "Previewer": {
-                        "BoundsEntity": ""
+                        "BoundsEntity": "Entity_[296994751178328]"
                     },
                     "Configuration": {
                         "StreamingImageAsset": {
@@ -1563,7 +1563,7 @@
                     "$type": "EditorImageGradientComponent",
                     "Id": 10707924659521035089,
                     "Previewer": {
-                        "BoundsEntity": ""
+                        "BoundsEntity": "Entity_[357799673674485]"
                     },
                     "Configuration": {
                         "StreamingImageAsset": {
@@ -1647,7 +1647,7 @@
                     "$type": "EditorImageGradientComponent",
                     "Id": 10707924659521035089,
                     "Previewer": {
-                        "BoundsEntity": ""
+                        "BoundsEntity": "Entity_[357812558576373]"
                     },
                     "Configuration": {
                         "StreamingImageAsset": {
@@ -1923,7 +1923,7 @@
                     "$type": "EditorImageGradientComponent",
                     "Id": 10707924659521035089,
                     "Previewer": {
-                        "BoundsEntity": ""
+                        "BoundsEntity": "Entity_[382784004585584]"
                     },
                     "Configuration": {
                         "StreamingImageAsset": {
@@ -2007,7 +2007,7 @@
                     "$type": "EditorImageGradientComponent",
                     "Id": 10707924659521035089,
                     "Previewer": {
-                        "BoundsEntity": ""
+                        "BoundsEntity": "Entity_[382814069356656]"
                     },
                     "Configuration": {
                         "StreamingImageAsset": {
@@ -6679,12 +6679,12 @@
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[16951455423041694634]/Transform Data/Translate/0",
-                    "value": -59.564151763916016
+                    "value": -66.56414794921875
                 },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[16951455423041694634]/Transform Data/Translate/1",
-                    "value": 32.441165924072266
+                    "value": 32.80604553222656
                 },
                 {
                     "op": "replace",
@@ -6710,7 +6710,7 @@
                 {
                     "op": "replace",
                     "path": "/Entities/Entity_[453802196716717]/Components/Component_[12122484710959107959]/Controller/Configuration/EditorEntityId",
-                    "value": 195231005818683466
+                    "value": 17158125052683578102
                 }
             ]
         },

+ 14 - 3
Project/Prefabs/Apple.prefab

@@ -96,7 +96,6 @@
                     "$type": "EditorColliderComponent",
                     "Id": 17352323353881558252,
                     "ColliderConfiguration": {
-                        "Trigger": true,
                         "MaterialSlots": {
                             "Slots": [
                                 {
@@ -167,8 +166,20 @@
                     "Id": 7138985039715548058,
                     "Configuration": {
                         "entityId": "",
-                        "Start Asleep": true,
-                        "Gravity Enabled": false
+                        "Gravity Enabled": false,
+                        "Kinematic": true,
+                        "Mass": 0.26808255910873413,
+                        "Inertia tensor": [
+                            0.00017157284310087562,
+                            0.0,
+                            0.0,
+                            0.0,
+                            0.00017157284310087562,
+                            0.0,
+                            0.0,
+                            0.0,
+                            0.00017157284310087562
+                        ]
                     }
                 },
                 "Component_[7230618248793844206]": {

+ 0 - 175
Project/Prefabs/AppleTreeApples.prefab

@@ -155,11 +155,6 @@
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
                     "value": -2.0386343002319336
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
-                    "value": -117.74958801269531
                 }
             ]
         },
@@ -341,11 +336,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/1",
                     "value": 0.15604059398174286
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
-                    "value": 1.9105675220489502
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
@@ -411,11 +401,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Parent Entity",
                     "value": "../ContainerEntity"
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/0",
-                    "value": 0.20024660229682922
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/1",
@@ -475,11 +460,6 @@
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
                     "value": -2.0386343002319336
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
-                    "value": -117.74958801269531
                 }
             ]
         },
@@ -1066,11 +1046,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 2.050983190536499
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
@@ -1146,16 +1121,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 1.3229258060455322
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -1186,16 +1151,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 0.957241952419281
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -1261,16 +1216,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/1",
                     "value": 0.15547695755958557
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -1341,16 +1286,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 1.7951061725616455
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -1891,11 +1826,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/0",
                     "value": 0.3189584016799927
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/1",
-                    "value": 0.023584745824337006
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
@@ -2261,16 +2191,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 0.957241952419281
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -2381,16 +2301,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 1.0460083484649658
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -2421,16 +2331,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 1.2811453342437744
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -2461,16 +2361,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 1.5594239234924316
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -2501,16 +2391,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 1.9802011251449585
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -2541,16 +2421,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 1.5999886989593506
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -2581,16 +2451,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 0.819862961769104
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -2621,16 +2481,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 0.7148736715316772
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -2701,16 +2551,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 0.7198629975318909
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -2746,11 +2586,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
                     "value": 1.8460960388183594
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",
@@ -2781,16 +2616,6 @@
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Translate/2",
                     "value": 1.5198630094528198
                 },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/0",
-                    "value": 1.8460938930511475
-                },
-                {
-                    "op": "replace",
-                    "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/1",
-                    "value": 12.610749244689941
-                },
                 {
                     "op": "replace",
                     "path": "/ContainerEntity/Components/Component_[17300195898860990188]/Transform Data/Rotate/2",

+ 15 - 11
Project/Scripts/DynamicAppleSpawner.lua

@@ -43,7 +43,7 @@ end
 function DynamicAppleSpawner:OnSpawn(spawnTicket, entityList)
 	-- first entity should be the root
 	table.insert(self.freeAppleGroups, entityList[1])
-	self:SetPhysicsEnabled(entityList[1], false)
+	--self:SetPhysicsEnabled(entityList[1], false)
 	local entityName  = GameEntityContextRequestBus.Broadcast.GetEntityName(entityList[1])
 	Debug.Log("$5 Spawned " .. tostring(entityName))
 	
@@ -51,12 +51,13 @@ function DynamicAppleSpawner:OnSpawn(spawnTicket, entityList)
 		self.spawningPrefabs = false
 	end 
 	
-	local children = TransformBus.Event.GetChildren(entityList[1])
-	for i=1,#children do
-		local childId = children[i]
-		local pos = TransformBus.Event.GetLocalTranslation(childId)
-		Debug.Log("("..tostring(pos.x)..","..tostring(pos.y)..","..tostring(pos.z).."),")
-	end
+	-- print out locations of every apple for scripting purposes
+	--local children = TransformBus.Event.GetChildren(entityList[1])
+	--for i=1,#children do
+	--	local childId = children[i]
+	--	local pos = TransformBus.Event.GetLocalTranslation(childId)
+	--	Debug.Log("("..tostring(pos.x)..","..tostring(pos.y)..","..tostring(pos.z).."),")
+	--end
 	
 	-- mark all follow targets to update in case they are waiting on groups
 	for k,followTarget in pairs(self.followTargets) do
@@ -173,8 +174,8 @@ function DynamicAppleSpawner:OnTick(delaTime, scriptTime)
 						-- remove this tree and free the apple group
 						if tree.applesEntityId ~= -1 then
 							table.insert(self.freeAppleGroups, tree.applesEntityId)
-							self:SetPhysicsEnabled(tree.applesEntityId, false)
-							TransformBus.Event.SetWorldTranslation(tree.applesEntityId, Vector3(0,0,1))
+							--self:SetPhysicsEnabled(tree.applesEntityId, false)
+							TransformBus.Event.SetWorldTranslation(tree.applesEntityId, Vector3(0,0,-10 * k))
 						end
 						table.insert(treesToRemove, tree.entityId)
 					end
@@ -199,9 +200,9 @@ function DynamicAppleSpawner:OnTick(delaTime, scriptTime)
 									Debug.Log("Claiming apple group " ..tostring(applesEntityId))
 								end
 								local treeTM = TransformBus.Event.GetWorldTM(entityId)
-								self:SetPhysicsEnabled(applesEntityId, false)
+								--self:SetPhysicsEnabled(applesEntityId, false)
 								TransformBus.Event.SetWorldTM(applesEntityId, treeTM)
-								self:SetPhysicsEnabled(applesEntityId, true)
+								--self:SetPhysicsEnabled(applesEntityId, true)
 								
 								-- hide the render meshes
 								RenderMeshComponentRequestBus.Event.SetVisibility(entityId, false)
@@ -249,6 +250,9 @@ function DynamicAppleSpawner:SpawnAppleGroup()
 	
 	local tm = TransformBus.Event.GetWorldTM(self.entityId)
 	local translation = tm:GetTranslation()
+	
+	-- move the prefabs down so they don't collide with eachother (safer than disabling/enabling physics)
+	translation.z = translation.z - self.numPrefabsSpawned * 10
 	local rotation = tm:GetRotation():GetEulerRadians()
 
 	Debug.Log("$7 Spawning apple group " .. tostring(self.numPrefabsSpawned ))