Generation issue fixed, closes #5
This commit is contained in:
@@ -29,10 +29,15 @@ public class LevelGenerator : MonoBehaviour
|
||||
|
||||
GenerateBlock();
|
||||
GenerateBlock();
|
||||
GenerateBlock();
|
||||
|
||||
}
|
||||
|
||||
float lastOffset=0;
|
||||
|
||||
|
||||
void GenerateBlock(){
|
||||
Debug.Log(lastOffset);
|
||||
float offset = lastOffset;
|
||||
SpriteShapeController spriteShapeController = Instantiate(spriteShapeControllerPrefab, new Vector3(offset,0),Quaternion.identity).GetComponent<SpriteShapeController>();
|
||||
spriteShapeController.spline.Clear();
|
||||
@@ -63,7 +68,7 @@ public class LevelGenerator : MonoBehaviour
|
||||
|
||||
Vector3 diff = points[i]-points[i-1];
|
||||
Vector2 newTreePosition2 = points[i-1] + (diff/2f) + new Vector3(lastOffset,0);
|
||||
Debug.Log($"{points[i-1]} + {points[i]} - {points[i-1]} / 0.5f | diff = {diff}");
|
||||
// Debug.Log($"{points[i-1]} + {points[i]} - {points[i-1]} / 0.5f | diff = {diff}");
|
||||
GameObject newTree = Instantiate(treePrefab, newTreePosition2, Quaternion.identity);
|
||||
newTree.transform.localScale = Vector3.one * Random.Range(0.75f, 1.1f);
|
||||
}
|
||||
@@ -84,7 +89,7 @@ public class LevelGenerator : MonoBehaviour
|
||||
}
|
||||
|
||||
points[LevelCount] = new Vector3(points[LevelCount-1].x+maxDiff.x, groundLevel);
|
||||
lastOffset = points[LevelCount].x - maxDiff.x;
|
||||
lastOffset += points[LevelCount].x - maxDiff.x;
|
||||
InsertNewPoint(spriteShapeController, points[LevelCount]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user