Random tree spawn

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?

Thank you ,
Sakuron :slight_smile:

i dont know much about scripting but i just watched a video and learned about instantiating and by the way im doing the same exact thing you are doing but i would try this EDIT:

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);

    }
}

END EDIT
put the tree in the var GameObject
fixed the problem with just spawning one tree just tweak the numbers a bit im still trying to work on the y axis so they dont float in the air and working on spreding them out