Browse Source

Tiling data and deloading past tiles

feature/routeTiling
Joshua 1 year ago
parent
commit
434557805b
12 changed files with 63 additions and 12 deletions
  1. BIN
      Assets/Data/Tiles/Bend_Left.asset
  2. +8
    -0
      Assets/Data/Tiles/Bend_Left.asset.meta
  3. BIN
      Assets/Data/Tiles/Bend_Right.asset
  4. +8
    -0
      Assets/Data/Tiles/Bend_Right.asset.meta
  5. BIN
      Assets/Prefab/Tile_01.prefab
  6. BIN
      Assets/Prefab/Tile_02.prefab
  7. +7
    -0
      Assets/Prefab/Tile_02.prefab.meta
  8. BIN
      Assets/Prefab/Tile_03.prefab
  9. +7
    -0
      Assets/Prefab/Tile_03.prefab.meta
  10. BIN
      Assets/Scenes/SampleScene.unity
  11. +8
    -2
      Assets/Scripts/Route/TileController.cs
  12. +9
    -6
      Assets/Scripts/Route/TileManager.cs

BIN
Assets/Data/Tiles/Bend_Left.asset (Stored with Git LFS) View File

size 502

+ 8
- 0
Assets/Data/Tiles/Bend_Left.asset.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e73daafd87f356a418683d515f657f1e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Data/Tiles/Bend_Right.asset (Stored with Git LFS) View File

size 502

+ 8
- 0
Assets/Data/Tiles/Bend_Right.asset.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5596d3ad400eb0f4a96bcfd82701418e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Prefab/Tile_01.prefab (Stored with Git LFS) View File

size 118408

BIN
Assets/Prefab/Tile_02.prefab (Stored with Git LFS) View File

size 118434

+ 7
- 0
Assets/Prefab/Tile_02.prefab.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: aee91d9e9e533ae48a241c35e7d37e4b
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Prefab/Tile_03.prefab (Stored with Git LFS) View File

size 118419

+ 7
- 0
Assets/Prefab/Tile_03.prefab.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9963b2a917f0e6946a7f8a8eecd0a128
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Scenes/SampleScene.unity (Stored with Git LFS) View File

size 24771

+ 8
- 2
Assets/Scripts/Route/TileController.cs View File

@ -8,6 +8,12 @@ public class TileController : MonoBehaviour
public Transform exitAnchor;
private void OnTriggerExit(Collider other)
{
if(other.transform.Equals(Camera.main.transform))
{
Destroy(gameObject, 1f);
}
}
}

+ 9
- 6
Assets/Scripts/Route/TileManager.cs View File

@ -10,9 +10,6 @@ public class TileManager : MonoBehaviour
[SerializeField]
private Transform m_camTransform;
[SerializeField]
private float m_exitCullDistance = 3f;
private int m_bendProfile = 0;
private TileController m_previousTile;
@ -34,7 +31,9 @@ public class TileManager : MonoBehaviour
// Update is called once per frame
void Update()
{
if(m_previousTile != null)
/*
if (m_previousTile != null)
{
if (Vector3.Distance(m_previousTile.transform.position, Camera.main.transform.position) > m_exitCullDistance)
{
@ -42,6 +41,7 @@ public class TileManager : MonoBehaviour
m_previousTile = null;
}
}
*/
if(Input.GetKeyDown(KeyCode.Space))
{
@ -58,17 +58,20 @@ public class TileManager : MonoBehaviour
{
_selectedTile = m_tileList[Random.Range(0, m_tileList.Count - 1)];
}
while (Mathf.Abs(m_bendProfile + (int)_selectedTile.tileType) < 2);
while (Mathf.Abs(m_bendProfile + (int)_selectedTile.tileType) >= 2);
m_bendProfile += (int)_selectedTile.tileType;
var _newTileObj = Instantiate(_selectedTile.prefab);
_newTileObj.transform.forward = m_currentTile.transform.forward;
_newTileObj.transform.forward = m_currentTile.exitAnchor.transform.forward;
var _newTileController = _newTileObj.GetComponent<TileController>();
Vector3 _offset = m_currentTile.exitAnchor.position - _newTileController.entryAnchor.position;
_newTileObj.transform.position += _offset;
m_previousTile = m_currentTile;
m_currentTile = _newTileController;
}
}

Loading…
Cancel
Save