Resolved merge conflicts
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SceneController : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbf8ab4673d6bf447aab098a12320431
|
||||
@@ -9,19 +9,23 @@ public class TreeSpawner : MonoBehaviour
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
// Debug.Log("TreeSpawner running");
|
||||
|
||||
if (hasSpawned) return;
|
||||
|
||||
if (player.position.y < transform.position.y - 3f)
|
||||
if (hasSpawned == false)
|
||||
{
|
||||
hasSpawned = true;
|
||||
if (player.position.y < transform.position.y - 3f)
|
||||
{
|
||||
hasSpawned = true;
|
||||
|
||||
float treeHeight = GetComponent<SpriteRenderer>().bounds.size.y;
|
||||
Vector3 spawnPos = (transform.position + Vector3.down * treeHeight) - new Vector3(0,-0.2f,0);
|
||||
float treeHeight = GetComponent<SpriteRenderer>().bounds.size.y;
|
||||
Vector3 spawnPos = transform.position + Vector3.down * treeHeight + new Vector3(0, 0.2f, 0);
|
||||
|
||||
Instantiate(treePrefab, spawnPos, Quaternion.identity);
|
||||
Instantiate(treePrefab, spawnPos, Quaternion.identity);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete trees that are far above the player
|
||||
if (player.position.y < transform.position.y - 40f)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user