ground destroy, instantiate

This commit is contained in:
2023-01-31 15:32:49 +01:00
parent 87008baf62
commit 2837b80902
35 changed files with 269 additions and 102 deletions

8
Assets/Resources.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 36d6112ecc1e7be4198fda8e9c1e7814
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -205,7 +205,7 @@ GameObject:
- component: {fileID: 4168203924951896375}
m_Layer: 0
m_Name: module1
m_TagString: Untagged
m_TagString: Ground
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0

View File

@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657832, g: 0.49641222, b: 0.57481664, a: 1}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@@ -123,6 +123,63 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &960528039
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 8284425857235584851, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_Name
value: module2 (1)
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_RootOrder
value: 6
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalPosition.z
value: 80
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalRotation.y
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 90
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
--- !u!1 &1201779180
GameObject:
m_ObjectHideFlags: 0
@@ -167,6 +224,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 84de2563cdee05b4a8d4e6fe329684a6, type: 3}
m_Name:
m_EditorClassIdentifier:
loadFrom: []
--- !u!4 &1201779183
Transform:
m_ObjectHideFlags: 0
@@ -180,8 +238,65 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1265567512
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 8284425857235584851, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_Name
value: module2 (2)
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_RootOrder
value: 7
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalPosition.z
value: 120
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalRotation.y
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 90
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
--- !u!1 &1895677325
GameObject:
m_ObjectHideFlags: 0
@@ -249,14 +364,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1895677325}
m_LocalRotation: {x: -0.2539846, y: 0.009283544, z: -0.0024363997, w: -0.96716064}
m_LocalPosition: {x: 0.0042525986, y: 4.9775524, z: -22.452322}
m_LocalRotation: {x: 0.2840022, y: -0.009203919, z: 0.0027263246, w: 0.9587756}
m_LocalPosition: {x: 0.01, y: 4.88, z: -22.19}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 33, y: -1.1, z: 0}
--- !u!1 &1980041874
GameObject:
m_ObjectHideFlags: 0
@@ -349,7 +464,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &30613582022879756
GameObject:
@@ -8340,7 +8455,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_RootOrder
value: 3
value: 5
objectReference: {fileID: 0}
- target: {fileID: 8769601115213192681, guid: f3082b8b00f0a10c48efb4c099b66852, type: 3}
propertyPath: m_LocalPosition.x
@@ -9561,7 +9676,7 @@ Transform:
- {fileID: 1969533545288908800}
- {fileID: 4837085586104442566}
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &7917514869596290072
BoxCollider:

View File

@@ -5,10 +5,13 @@ using UnityEngine;
public class GroundController : MonoBehaviour
{
private GameObject[] ground;
public GameObject[] loadFrom;
private float groundMoveSpeed = 10f;
private void Awake() {
LoadPrefabs("Prefabs/Modulok");
Debug.Log(loadFrom.Length);
//getting all of the ground objects by the tag
ground = GameObject.FindGameObjectsWithTag("Ground");
if(ground.Length == 0){
@@ -19,17 +22,58 @@ public class GroundController : MonoBehaviour
}
private void Update() {
for (int i = 0; i < ground.Length; i++)
{
ground = GameObject.FindGameObjectsWithTag("Ground"); //torles miatt ujra le kell kerni a ground objecteket
OrderGroundArrayByZ(); //rendezzuk z szerint hogy sorba legyenek
for (int i = 0; i < ground.Length; i++){ //ground objecteket mozgatja
ground[i].transform.position = ground[i].transform.position + new Vector3(0,0, -groundMoveSpeed * Time.deltaTime);
}
//uj ground letrehozas
if(ground[ground.Length-1].transform.position.z <= 80){
CreateNewGround();
}
//ellenorzi hogy torolheto e az object
foreach (var item in ground){
if(CheckGroundToDestroy(item)){
Destroy(item);
}
}
}
private void CheckGroundToDestroy(){
private void LoadPrefabs(string path){ //toltese be a palya objecteket a resources mappabol pl: "Prefabs/Modulok"
loadFrom = Resources.LoadAll<GameObject>(path);
}
private bool CheckGroundToDestroy(GameObject toCheck){
//z = -80 -nal lehet torolni
if(ground[0].transform.position.z == 0){
if(toCheck.transform.position.z <= -80){
Debug.Log("elerte " + toCheck.name);
return true; //torolheto
}
return false; //nem torolheto
}
private void OrderGroundArrayByZ(){
GameObject csere;
for (int i = 0; i < ground.Length; i++){
for(int j = 0; j < i; j++){
if(ground[j].transform.position.z > ground[j+1].transform.position.z){
csere = ground[j];
ground[j] = ground[j+1];
ground[j+1] = csere;
}
}
}
}
private void CreateNewGround(){
int random = UnityEngine.Random.Range(0, loadFrom.Length);
//ketto modullal elobb tolt be, annak az iranyanak megfeleloen, +80 a ket modull hossza
Instantiate(loadFrom[random], new Vector3(0,0, ground[ground.Length-2].transform.position.z + 80), ground[ground.Length-2].transform.rotation);
}
}

View File

@@ -15,11 +15,11 @@ MonoBehaviour:
m_PixelRect:
serializedVersion: 2
x: 0
y: 28
width: 1366
height: 672
y: 43
width: 1920
height: 997
m_ShowMode: 4
m_Title: Project
m_Title: Hierarchy
m_RootView: {fileID: 3}
m_MinSize: {x: 875, y: 371}
m_MaxSize: {x: 10000, y: 10000}
@@ -39,10 +39,10 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 727
x: 883
y: 0
width: 251
height: 357
width: 562
height: 544
m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 13}
@@ -70,8 +70,8 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1366
height: 672
width: 1920
height: 997
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
m_UseTopView: 1
@@ -95,7 +95,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1366
width: 1920
height: 30
m_MinSize: {x: 0, y: 0}
m_MaxSize: {x: 0, y: 0}
@@ -116,8 +116,8 @@ MonoBehaviour:
m_Position:
serializedVersion: 2
x: 0
y: 652
width: 1366
y: 977
width: 1920
height: 20
m_MinSize: {x: 0, y: 0}
m_MaxSize: {x: 0, y: 0}
@@ -140,12 +140,12 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 30
width: 1366
height: 622
width: 1920
height: 947
m_MinSize: {x: 400, y: 200}
m_MaxSize: {x: 32384, y: 16192}
vertical: 0
controlID: 132
controlID: 63
--- !u!114 &7
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -165,12 +165,12 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 978
height: 622
width: 1445
height: 947
m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192}
vertical: 1
controlID: 133
controlID: 64
--- !u!114 &8
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -191,12 +191,12 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 978
height: 357
width: 1445
height: 544
m_MinSize: {x: 300, y: 100}
m_MaxSize: {x: 24288, y: 8096}
vertical: 0
controlID: 72
controlID: 65
--- !u!114 &9
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -214,8 +214,8 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 225
height: 357
width: 260
height: 544
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 14}
@@ -238,12 +238,12 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 225
x: 260
y: 0
width: 502
height: 357
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
width: 623
height: 544
m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 15}
m_Panes:
- {fileID: 15}
@@ -265,9 +265,9 @@ MonoBehaviour:
m_Position:
serializedVersion: 2
x: 0
y: 357
width: 978
height: 265
y: 544
width: 1445
height: 403
m_MinSize: {x: 231, y: 271}
m_MaxSize: {x: 10001, y: 10021}
m_ActualView: {fileID: 16}
@@ -291,10 +291,10 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 978
x: 1445
y: 0
width: 388
height: 622
width: 475
height: 947
m_MinSize: {x: 276, y: 71}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 18}
@@ -322,10 +322,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 727
y: 86
width: 249
height: 336
x: 883
y: 73
width: 560
height: 523
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -336,7 +336,7 @@ MonoBehaviour:
m_ShowGizmos: 0
m_TargetDisplay: 0
m_ClearColor: {r: 0, g: 0, b: 0, a: 0}
m_TargetSize: {x: 249, y: 315}
m_TargetSize: {x: 560, y: 502}
m_TextureFilterMode: 0
m_TextureHideFlags: 61
m_RenderIMGUI: 1
@@ -351,10 +351,10 @@ MonoBehaviour:
m_VRangeLocked: 0
hZoomLockedByDefault: 0
vZoomLockedByDefault: 0
m_HBaseRangeMin: -124.5
m_HBaseRangeMax: 124.5
m_VBaseRangeMin: -157.5
m_VBaseRangeMax: 157.5
m_HBaseRangeMin: -280
m_HBaseRangeMax: 280
m_VBaseRangeMin: -251
m_VBaseRangeMax: 251
m_HAllowExceedBaseRangeMin: 1
m_HAllowExceedBaseRangeMax: 1
m_VAllowExceedBaseRangeMin: 1
@@ -372,23 +372,23 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 21
width: 249
height: 315
width: 560
height: 502
m_Scale: {x: 1, y: 1}
m_Translation: {x: 124.5, y: 157.5}
m_Translation: {x: 280, y: 251}
m_MarginLeft: 0
m_MarginRight: 0
m_MarginTop: 0
m_MarginBottom: 0
m_LastShownAreaInsideMargins:
serializedVersion: 2
x: -124.5
y: -157.5
width: 249
height: 315
x: -280
y: -251
width: 560
height: 502
m_MinimalGUI: 1
m_defaultScale: 1
m_LastWindowPixelSize: {x: 249, y: 336}
m_LastWindowPixelSize: {x: 560, y: 523}
m_ClearInEditMode: 1
m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 01000000000000000000
@@ -415,9 +415,9 @@ MonoBehaviour:
m_Pos:
serializedVersion: 2
x: 0
y: 86
width: 224
height: 336
y: 73
width: 259
height: 523
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -425,9 +425,9 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: d80a0000
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: e8faffff32fbffff34fbffff
m_ExpandedIDs: de81ffff2882ffff7282ffff1aeeffff
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -471,10 +471,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 225
y: 86
width: 500
height: 336
x: 260
y: 73
width: 621
height: 523
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -676,9 +676,9 @@ MonoBehaviour:
m_PlayAudio: 0
m_AudioPlay: 0
m_Position:
m_Target: {x: -11.238202, y: -22.887142, z: -40.634796}
m_Target: {x: -8.353775, y: 7.685253, z: 62.741096}
speed: 2
m_Value: {x: -11.238202, y: -22.887142, z: -40.634796}
m_Value: {x: -8.353775, y: 7.685253, z: 62.741096}
m_RenderMode: 0
m_CameraMode:
drawMode: 0
@@ -725,13 +725,13 @@ MonoBehaviour:
m_GridAxis: 1
m_gridOpacity: 0.5
m_Rotation:
m_Target: {x: -0.28534734, y: 0.19575526, z: -0.059655692, w: -0.93632853}
m_Target: {x: -0.03701341, y: 0.9162654, z: -0.087132014, w: -0.3892271}
speed: 2
m_Value: {x: -0.28534546, y: 0.19575398, z: -0.0596553, w: -0.9363224}
m_Value: {x: -0.037144028, y: 0.91567963, z: -0.0870763, w: -0.39060065}
m_Size:
m_Target: 43.63697
m_Target: 64.9515
speed: 2
m_Value: 43.63697
m_Value: 64.9515
m_Ortho:
m_Target: 0
speed: 2
@@ -777,9 +777,9 @@ MonoBehaviour:
m_Pos:
serializedVersion: 2
x: 0
y: 443
width: 977
height: 244
y: 617
width: 1444
height: 382
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -797,22 +797,22 @@ MonoBehaviour:
m_SkipHidden: 0
m_SearchArea: 1
m_Folders:
- Assets/Scripts
- Assets/Resources/Prefabs/Modulok
m_Globs: []
m_OriginalText:
m_ViewMode: 1
m_StartGridSize: 58
m_StartGridSize: 81
m_LastFolders:
- Assets/Scripts
m_LastFoldersGridSize: 58
m_LastProjectPath: /home/tom/Documents/dev/zarodolgozat/ColorRunner
- Assets/Resources/Prefabs/Modulok
m_LastFoldersGridSize: 81
m_LastProjectPath: C:\dev\zarodolgozat\ColorBall
m_LockTracker:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 16}
m_SelectedIDs: 74600000
m_LastClickedID: 24692
m_ExpandedIDs: 000000004460000000ca9a3bffffff7f
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 38ea0000
m_LastClickedID: 59960
m_ExpandedIDs: 00000000686d00008c6d00008e6d000024ea0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -840,7 +840,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 0000000044600000
m_ExpandedIDs: 00000000686d0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -868,7 +868,7 @@ MonoBehaviour:
m_SelectedInstanceIDs:
m_LastClickedInstanceID: 0
m_HadKeyboardFocusLastEvent: 1
m_ExpandedInstanceIDs: c6230000
m_ExpandedInstanceIDs: c6230000745c0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -893,7 +893,7 @@ MonoBehaviour:
m_ResourceFile:
m_NewAssetIndexInList: -1
m_ScrollPosition: {x: 0, y: 0}
m_GridSize: 58
m_GridSize: 81
m_SkipHiddenPackages: 0
m_DirectoriesAreaWidth: 207
--- !u!114 &17
@@ -917,9 +917,9 @@ MonoBehaviour:
m_Pos:
serializedVersion: 2
x: 0
y: 443
width: 977
height: 244
y: 617
width: 1444
height: 382
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -944,10 +944,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 978
y: 86
width: 387
height: 601
x: 1445
y: 73
width: 474
height: 926
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default