Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class FloorManager : MonoBehaviour {
- public Transform[] m_aFloorParts;
- public float m_fFloorStartZ;
- public float m_fFloorEndZ;
- public float m_fMovementSpeed;
- void Start () {
- float fZpos = 0.0f;
- float fFloorLength = Mathf.Abs(m_fFloorStartZ) + Mathf.Abs(m_fFloorEndZ);
- Debug.Log("Floor Length is: " + fFloorLength.ToString());
- while(fZpos > -fFloorLength) {
- SpawnNewFloor(fZpos);
- fZpos -= 5.0f;
- }
- }
- public void SpawnNewFloor(float fZOffset) {
- Debug.Log(fZOffset);
- Transform tFloorT = Instantiate(
- m_aFloorParts[Random.Range(0, m_aFloorParts.Length - 1)],
- new Vector3(0.0f, 0.0f, m_fFloorStartZ + fZOffset),
- Quaternion.identity);
- if( null == tFloorT){
- Debug.LogError("Unable to spawn!");
- return;
- }
- ScrollingItem gcFloorPart = tFloorT.GetComponent<ScrollingItem>();
- if(null == gcFloorPart){
- Debug.LogError("Prefab doesn't have a Scrolling Item component.");
- return;
- }
- gcFloorPart.m_fEndZ = m_fFloorEndZ;
- gcFloorPart.m_fStartZ = m_fFloorStartZ + fZOffset;
- gcFloorPart.m_fMovementSpeed = m_fMovementSpeed;
- }
- // Update is called once per frame
- void Update () {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement