feat: 지형에 MeshCollider 추가하여 물리 엔진(공 등) 상호작용 지원

main
hotunecookie 4 weeks ago
parent 8c3c3a452f
commit 8004af59e7

@ -129,8 +129,8 @@ Material:
- _XRMotionVectorsPass: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _BaseColor: {r: 0.9958072, g: 0.7607278, b: 0.4394495, a: 1}
- _Color: {r: 0.9958071, g: 0.7607278, b: 0.43944946, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

File diff suppressed because one or more lines are too long

@ -183,6 +183,9 @@ public class TerrainCreatorEditor : Editor
MeshFilter mf = terrainObj.AddComponent<MeshFilter>();
mf.sharedMesh = mesh;
MeshCollider mc = terrainObj.AddComponent<MeshCollider>();
mc.sharedMesh = mesh;
MeshRenderer mr = terrainObj.AddComponent<MeshRenderer>();
if (creator.terrainMaterial != null)
{
@ -259,7 +262,7 @@ public class TerrainCreatorEditor : Editor
TreeRandomPreset p = creator.preset;
if (depth >= p.maxDepth) return;
float currentLength = isRoot ? 2f : length * p.scaleFactor * Random.Range(1f - p.scaleRandom, 1f + p.scaleRandom);
float currentLength = isRoot ? 5f : length * p.scaleFactor * Random.Range(1f - p.scaleRandom, 1f + p.scaleRandom);
GameObject pivot = new GameObject($"Pivot_D{depth}");
pivot.transform.SetParent(parent, false);
@ -280,8 +283,9 @@ public class TerrainCreatorEditor : Editor
branchObj.transform.localPosition = Vector3.up * currentLength * 0.5f;
branchObj.transform.localRotation = Quaternion.identity;
float thickness = 0.2f * (p.maxDepth - depth) / p.maxDepth;
branchObj.transform.localScale = new Vector3(thickness, currentLength * 0.5f, thickness);
float thickness = 0.15f * (p.maxDepth - depth);
float lengthScale = creator.branchPrefab != null ? currentLength : currentLength * 0.5f;
branchObj.transform.localScale = new Vector3(thickness, lengthScale, thickness);
Renderer rnd = branchObj.GetComponentInChildren<Renderer>();
if (rnd != null)
@ -293,6 +297,7 @@ public class TerrainCreatorEditor : Editor
MaterialPropertyBlock mpb = new MaterialPropertyBlock();
rnd.GetPropertyBlock(mpb);
mpb.SetColor("_Color", baseColor);
mpb.SetColor("_BaseColor", baseColor);
rnd.SetPropertyBlock(mpb);
}

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c7a0c2a598d6efa45ab3f1602e5cc835, type: 3}
m_Name: TreeRandomPreset
m_EditorClassIdentifier: Assembly-CSharp::TreeRandomPreset
maxDepth: 8
maxDepth: 4
branchAngle: 30
scaleFactor: 0.7
twistAngle: 90

Loading…
Cancel
Save