Hi,
I’m total new in Unity and i just now the basics. I want to make a simple survival game. I already have 3 types of trees, but here’s my problem :
I want to place the trees randomly on my terrain every time a new game is started. But the trees should only spawn in a curtain area.I’m also trying to spawn one tree every day in game or something.
I haven’t found anything useful yet. Can you please give me some clues how I can manage this?
like i said before in your other post use this script:
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
public GameObject tree;
public int number;
public int xaxis;
public int yaxis;
public int zaxis;
void Start () {
PlaceTree ();}
void PlaceTree(){
for(int i = 0; i < number;i++){
Instantiate(tree,GeneratedPosition(),Quaternion.identity);
}
}
Vector3 GeneratedPosition(){
int x,y,z;
x = UnityEngine.Random.Range (-xaxis, xaxis);
y = UnityEngine.Random.Range (-yaxis, yaxis);
z = UnityEngine.Random.Range (-zaxis, zaxis);
return new Vector3 (x,y,z);
}
}