Quantcast
Channel: Questions in topic: "endless"
Viewing all articles
Browse latest Browse all 123

Trouble spawning endless platform

$
0
0
I'm having trouble spawning platforms for an endless runner/faller type game. Mine is an endless faller, so I think you can imagine what I'm trying to do. The problem I get is I always have a gap in between at least 1 of them. The gap grows a bit sometimes. If I don't have the .2f added in, the gaps are even worse. When I speed the moving up even a bit, the gaps are about half an inch thick. This is driving me crazy. I've searched all over the forums for the answer to this. I always see people saying to use += so you won't have gaps, but that is not working at all for me. Anyone have any idea what to do? Thanks! Here is what I have right now. Spawning script: using UnityEngine; using System.Collections; public class WallSpawnScript : MonoBehaviour { Vector3 zeroPos = new Vector3(0, 10f,0); public void WallSpawn() { int objToSpawn = Random.Range (1,2); switch(objToSpawn) { case 1: Debug.Log ("hit"); var obj = SmartPool.Spawn ("Wall1"); obj.transform.position = zeroPos; Vector3 pos1 = new Vector3(0,((obj.transform.localScale.z * -3) + .2f), 0); obj.transform.position += pos1; break; case 2: Debug.Log ("hit"); var obj2 = SmartPool.Spawn ("Wall2"); obj2.transform.position = zeroPos; Vector3 pos2 = new Vector3(0,((obj2.transform.localScale.z * -3) + .2f), 0); obj2.transform.position += pos2; break; } } } Object Script: using UnityEngine; using System.Collections; public class WallScript1 : MonoBehaviour { public WallSpawnScript WallSpawnScript; void Update () { this.transform.Translate(0, 0, 10 * Time.deltaTime); if(this.transform.localPosition.y > 10) { SmartPool.Despawn(gameObject); WallSpawnScript.WallSpawn(); } } }

Viewing all articles
Browse latest Browse all 123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>