-
Notifications
You must be signed in to change notification settings - Fork 1
Drawing
trk20 edited this page May 31, 2026
·
4 revisions
The Drawing static class provides 3D shape rendering for debugging, visualization, and visual feedback. Shapes are drawn in world space and automatically expire after a set duration.
using static FtDSharp.Drawing;-
duration = 1(default) — shape lasts 1 game frame, then disappears -
duration = 40— shape persists for 40 frames (~1 second at 1x speed) -
fade = true— shape fades out over its duration
For continuous visualization, draw shapes every frame in your [OnPhysicsTick] method with duration: 1.
Draws an arrow from one point to another with an arrowhead.
Arrow(Vector3 start, Vector3 end, Color color, float width = 2, float duration = 1, bool fade = false)Arrow(weapon.WorldPosition, weapon.WorldPosition + weapon.AimDirection * 30f, Color.green);Draws a line between two points.
Line(Vector3 start, Vector3 end, Color color, float width = 2, float duration = 1, bool fade = false)Line(missile.Position, target.Position, Color.red, width: 1f);Draws a point marker at a position.
Point(Vector3 position, Color color, float size = 2, float duration = 1, bool fade = false)Point(turret.WorldPosition, Color.yellow, size: 3f);Draws a 3D cross (6 lines along all axes). Good for marking positions clearly.
Cross(Vector3 position, Color color, float width = 2, float scale = 1, float duration = 1, bool fade = false)Cross(target.Position, Color.red, scale: 5f);Draws a wireframe sphere (3 perpendicular circles).
Sphere(Vector3 position, float radius, Color color, float width = 2, float duration = 1, bool fade = false)Sphere(target.Position, radius: 20f, Color.red);
Sphere(ally.Position, radius: 10f, Color.blue);Draws a circle with a specified normal direction or rotation.
Circle(Vector3 position, float radius, Color color, Vector3 normal, float width = 2, float duration = 1, bool fade = false)
Circle(Vector3 position, float radius, Color color, Quaternion rotation, float width = 2, float duration = 1, bool fade = false)// Horizontal circle (normal pointing up)
Circle(myPos, 50f, Color.green, Vector3.up);
// Circle aligned to construct rotation
Circle(myPos, 30f, Color.blue, Game.MainConstruct.Rotation);Draws three axis-colored circles (red=X, green=Y, blue=Z) showing orientation.
Gimbal(Vector3 position, float radius, Quaternion rotation, float width = 2, float duration = 1)Gimbal(Game.MainConstruct.Position, 15f, Game.MainConstruct.Rotation);Removes all currently drawn shapes.
Clear();| Parameter | Default |
|---|---|
width |
2f |
duration |
1f (1 frame) |
fade |
false |
scale (Cross) |
1f |
size (Point) |
2f |
var target = AI.HighestPriorityMainframe.PrimaryTarget;
if (target != null)
{
Sphere(target.Position, 5f, Color.red);
Arrow(Game.MainConstruct.Position, target.Position, Color.yellow);
}foreach (var weapon in Weapons.All)
{
var color = weapon.CanFire ? Color.green : (weapon.CanAim ? Color.yellow : Color.red);
Arrow(weapon.WorldPosition, weapon.WorldPosition + weapon.AimDirection * 20f, color, width: 1f);
}// Horizontal engagement range circle
Circle(Game.MainConstruct.Position, 500f, Color.green, Vector3.up, width: 1f);foreach (var warning in Warnings.IncomingProjectiles)
{
Cross(warning.Position, Color.red, scale: 3f);
Arrow(warning.Position, warning.Position + warning.Velocity.normalized * 20f, Color.red, width: 1f);
}public class DebugHUD
{
[OnPhysicsTick]
public void Update()
{
var pos = Game.MainConstruct.Position;
var rot = Game.MainConstruct.Rotation;
// Orientation gimbal
Gimbal(pos + Vector3.up * 20f, 10f, rot);
// Range rings
Circle(pos, 200f, Color.yellow, Vector3.up, width: 1f);
Circle(pos, 500f, Color.green, Vector3.up, width: 1f);
// Targets
foreach (var target in AI.HighestPriorityMainframe.Targets)
Sphere(target.Position, 8f, Color.red);
// Friendlies
foreach (var ally in Friendly.AllExcludingSelf)
Sphere(ally.Position, 8f, Color.blue);
// Incoming
foreach (var warning in Warnings.IncomingProjectiles)
Cross(warning.Position, Color.magenta, scale: 4f);
}
}