I want to draw a half circle, and in the future draw smaller and bigger pie shapes.
I cannot get the math right. It is showing as I want when the object is at 0,0,0 but it changes when the object is moved. I want the same shape and size to follow the object. Also, I want it to respect Y-axis rotation.
It is a gizmo for showing the object’s detection area.
Does anyone know the correct settings to use for this?
Here is the code I have now:
public class GetStartedGizmos : MonoBehaviourGizmos {
public override void DrawGizmos () {
using (Draw.InLocalSpace(transform)) {
// Draw a cylinder at the object's position with a height of 2 and a radius of 0.5
if (GizmoContext.InSelection(this))
{
var a1 = Mathf.PI * 0f;
var a2 = Mathf.PI * 1f;
var size = 8f;
var arcStart = new Vector3(Mathf.Cos(a1), 0, Mathf.Sin(a1));
var arcEnd = new Vector3(Mathf.Cos(a2), 0, Mathf.Sin(a2));
var arcColor = Color.cyan * new Color(1, 1, 1, 0.5f);
var startPoint = this.transform.position;
Draw.Line(startPoint, arcStart * size, arcColor);
Draw.Line(startPoint, arcEnd * size, arcColor);
Draw.Arc(startPoint, arcStart * size, arcEnd * size, arcColor);
Draw.ArrowheadArc(startPoint, new float3(0,0,1f), 1f, arcColor);
}
}
}
}