Fix cone make it look nice

This commit is contained in:
Ben Calegari 2026-06-23 23:11:48 -07:00
parent 4f57499e40
commit c5c02ecc7e
2 changed files with 11 additions and 4 deletions

View file

@ -254,9 +254,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 93bc533262394e1e8b122bbfad89391a, type: 3} m_Script: {fileID: 11500000, guid: 93bc533262394e1e8b122bbfad89391a, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: Assembly-CSharp::TD.Visuals.ConeMesh m_EditorClassIdentifier: Assembly-CSharp::TD.Visuals.ConeMesh
sides: 16 sides: 4
radius: 0.5 radius: 0.7071068
height: 1 height: 1.5
angularOffsetDegrees: 45
--- !u!1 &7580197837852108944 --- !u!1 &7580197837852108944
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -37,6 +37,11 @@ namespace TD.Visuals
[Min(0.001f)] [Min(0.001f)]
[SerializeField] private float height = 1f; [SerializeField] private float height = 1f;
[Tooltip("Rotation of the base ring around the vertical axis, in degrees. With a low " +
"side count this makes a pyramid; e.g. sides = 4 with a 45° offset and " +
"radius 0.7071 yields a square-based pyramid whose faces align to the X/Z axes.")]
[SerializeField] private float angularOffsetDegrees = 0f;
private Mesh mesh; private Mesh mesh;
private void OnEnable() => Rebuild(); private void OnEnable() => Rebuild();
@ -89,7 +94,8 @@ namespace TD.Visuals
var vertices = new Vector3[sides + 2]; var vertices = new Vector3[sides + 2];
for (int i = 0; i < sides; i++) for (int i = 0; i < sides; i++)
{ {
float angle = (i / (float)sides) * Mathf.PI * 2f; float angle = (i / (float)sides) * Mathf.PI * 2f
+ angularOffsetDegrees * Mathf.Deg2Rad;
vertices[baseRingStart + i] = new Vector3( vertices[baseRingStart + i] = new Vector3(
Mathf.Cos(angle) * radius, Mathf.Cos(angle) * radius,
-halfHeight, -halfHeight,