プロシージャルシティ生成はどんな方法で行うべきか知りたい

知りたい事

プロシージャルで都会の町のマップ生成の手法が知りたいです

実現したい事

最終的にはランダムな都会町を生成したいのですがとりえず、直線の道路を生成してその両方の端に建物をランダムに配置する方法が知りたいです。とりえず乱数を用いて下記のコードのように行ったのですが。もう少し仕様が追加されて際に拡張性がなさ過ぎてどうすればいいのか知りたいです。そもそもどうような手法を用いのでしょうか?

仕様

X軸、Y軸、Z軸、で大きさが異なる建物と道路のオブジェクトがあります。

試したこと

取りえず、乱数で表示を試しましたが拡張性がありません。
ChatGDTを活用

とりあえずのソースコード

cs

1using System.Collections;2using System.Collections.Generic;3using UnityEngine;4 5public class StageManage : MonoBehaviour6{7 public List<GameObject> list;8 public GameObject roadObject;9 10 11 Vector3 position = new Vector3();12 // Start is called before the first frame update13 void Start()14 {15 16 Random.InitState(10);17 18 19 20 for(int i = 0; i < 10; i++)21 {22 int rand = Random.Range(0,list.Count);23 24 GameObject g = Instantiate(list[rand],transform);25 //GameObject g = Instantiate(list[1],transform);26 27 28 position.x += g.GetComponent<Renderer>().bounds.size.x / 2;29 30 g.transform.position = position;31 Debug.Log(position.x ); 32 }33 34 35 Vector3 pos = new Vector3();36 for(int i = 0; i < position.x; i += 2)37 {38 GameObject gg = Instantiate(roadObject,transform);39 40 gg.transform.position = pos;41 pos.x += 2;42 }43 44 }45 46 // Update is called once per frame47 void Update()48 {49 50 }51}

コメントを投稿

0 コメント