I am just getting started with BD, and I'm really enjoying what ive seen so far!
I am trying to implement a version of the behaviour tree tutorial's CanSeeObject in my own project, and everything seems to be working well so far, but ive come across a small snag i cant seem to sort out!
Everything works as intended while in edit mode, but if i press play, my gizmo disappears! The Behaviour Tree Gizmos are enabled in both play and edit mode, but seems to stop being called in play mode. (the debug confirms this by stopping after about 100 frames in play mode.
Edit Mode:
Play Mode:
The Gizmo Shows up for the first 100 or so frames, then stops.
This might just be a setting or something, but I cant for the life of me figure it out! Any advice would be welcome!
Thanks for your time! <3
I am trying to implement a version of the behaviour tree tutorial's CanSeeObject in my own project, and everything seems to be working well so far, but ive come across a small snag i cant seem to sort out!
Everything works as intended while in edit mode, but if i press play, my gizmo disappears! The Behaviour Tree Gizmos are enabled in both play and edit mode, but seems to stop being called in play mode. (the debug confirms this by stopping after about 100 frames in play mode.
public override void OnDrawGizmos()
{
DrawWireArc(Owner.transform.position, Owner.transform.forward, fieldOfViewAngle.Value, viewDistance.Value);
Debug.Log("Drawing Gizmo"); //
}
public void DrawWireArc(Vector3 position, Vector3 dir, float anglesRange, float radius, float maxSteps = 20)
{
var srcAngles = GetAnglesFromDir(position, dir);
var initialPos = position;
var posA = initialPos;
var stepAngles = anglesRange / maxSteps;
var angle = srcAngles - anglesRange / 2;
Gizmos.color = gizmoColor;
for (var i = 0; i <= maxSteps; i++)
{
var rad = Mathf.Deg2Rad * angle;
var posB = initialPos;
posB += new Vector3(radius * Mathf.Cos(rad), radius * Mathf.Sin(rad), 0);
Gizmos.DrawLine(posA, posB);
angle += stepAngles;
posA = posB;
}
Gizmos.DrawLine(posA, initialPos);
}
static float GetAnglesFromDir(Vector3 position, Vector3 dir)
{
var forwardLimitPos = position + dir;
var srcAngles = Mathf.Rad2Deg * Mathf.Atan2(forwardLimitPos.z - position.z, forwardLimitPos.x - position.x);
return srcAngles;
}
Edit Mode:
Play Mode:
The Gizmo Shows up for the first 100 or so frames, then stops.
This might just be a setting or something, but I cant for the life of me figure it out! Any advice would be welcome!
Thanks for your time! <3