void Update () {
var gObj = GameObject.Find("Player");
Debug.Log(gObj.transform.position);
}
Basic concept of endless scroller, not sure the code works exactly and is current, but basic concept:
using UnityEngine;
using System.Collections;
public class GroundSpawner : MonoBehaviour {
public GameObject[] prefabs;
public float spawnDistance;
private GameObject playerLastPosition;
private GameObject playerPosition;
float distanceTravelled = 0;
Vector3 lastPosition;
// Use this for initialization
void Start () {
// infinite coin spawning function, asynchronous
//StartCoroutine(SpawnGround());
playerPosition = GameObject.Find("Player");
lastPosition = playerPosition.transform.position;
}
// Update is called once per frame
void Update () {
distanceTravelled += Vector3.Distance(playerPosition.transform.position, lastPosition);
lastPosition = playerPosition.transform.position;
Debug.Log("distanceTravelled is " + distanceTravelled);
}
}