Overview
VectorDisplaySettings is a custom Resource class that stores all configuration for how vectors are displayed. Using a resource instead of direct properties provides powerful benefits.
vector_display_settings.gd:1-2
Settings are organized into export groups: Show, Rendering, Colors, and Color dimming.
Why Use Resources?
Resources provide several advantages over direct node properties:Shareability
MultipleVectorDisplay2D nodes can reference the same settings resource:
Runtime Configuration
Resources can be created and modified at runtime:Automatic Change Signals
Resources emit achanged signal when any property is modified:
vector_display_2d.gd:22
How the changed signal works
How the changed signal works
Godot automatically emits the
changed signal when any @export property on a Resource is modified, either in the editor or at runtime. The VectorDisplay2D node connects to this signal once in _ready(), and then any settings modification automatically triggers a visual update.Show Settings
Controls visibility of the visualization.show_vectors
vector_display_settings.gd:12
- Toggle at runtime to hide/show visualization
- Can be controlled by the keyboard shortcut
- Checked first in
_draw()for early return
show_axes
vector_display_settings.gd:14
false
Enabling axes helps visualize vector decomposition, useful for understanding movement in each direction independently.
Rendering Settings
Controls how vectors are drawn and transformed.vector_scale
vector_display_settings.gd:20
This scaling is purely visual and doesn’t affect the actual vector values. Applied in
_process() before rendering.width
vector_display_settings.gd:23
length_mode
vector_display_settings.gd:26
- Normal - Display actual vector length (scaled)
- Clamp - Limit maximum length to
max_length - Normalize - Always show at exactly
max_length
vector_display_functions.gd:24-30
When to use each mode
When to use each mode
Normal - Default mode, shows true vector magnitudeClamp - Useful when vectors can become extremely large but you want to see direction. Examples:
- High-speed physics objects
- Uncapped velocity systems
- Preventing visual overflow
- Directional indicators
- Movement input visualization
- Comparing angles between different vectors
max_length
vector_display_settings.gd:29
arrowhead
vector_display_settings.gd:32
true
Arrowheads automatically hide when vectors become very small to prevent visual clutter.
arrowhead_size
vector_display_settings.gd:35
vector_display_2d.gd:70
pivot_mode
vector_display_settings.gd:38
- Normal - Vector starts from origin (0, 0)
- Centered - Vector is centered at origin
vector_display_functions.gd:78-85
Visual comparison
Visual comparison
Normal mode:Centered mode:
axes_pivot_mode
vector_display_settings.gd:41
- Same - Use same pivot mode as main vector
- Normal - Force Normal mode for axes
- Centered - Force Centered mode for axes
"Same" (recommended)
Keeping this at “Same” is highly recommended for consistent visualization. Override only for specific visual effects.
Color Settings
Controls the color scheme for vectors and components.main_color
vector_display_settings.gd:47
x_axis_color
vector_display_settings.gd:50
show_axes is enabled.
Default: Red
y_axis_color
vector_display_settings.gd:53
show_axes is enabled.
Default: Green
The RGB color scheme (Red=X, Green=Y, Blue=Z) follows common 3D graphics conventions and will extend naturally when 3D support is added.
rainbow
vector_display_settings.gd:59
false
Implementation:
vector_display_functions.gd:46-51
- 0° (right) = Red
- 90° (up) = Cyan
- 180° (left) = Green
- 270° (down) = Magenta
Rainbow vs main_color
Rainbow vs main_color
When
rainbow = true, the dynamically calculated color overrides main_color. The axis colors (x_axis_color, y_axis_color) are not affected by rainbow mode.Color Dimming Settings
Advanced color effects based on vector magnitude.dimming
vector_display_settings.gd:65
false
Dimming makes vectors fade toward a fallback color as they get shorter, providing visual feedback about magnitude.
dimming_speed
vector_display_settings.gd:68
vector_display_functions.gd:60-62
fallback_color
vector_display_settings.gd:71
vector_display_functions.gd:64-67
normalized_dimming_type
vector_display_settings.gd:74
- None - Disable dimming when using Normalize mode
- Absolute - Dim based on actual vector magnitude (before normalization)
- Visual - Dim based on displayed length (always at max_length, so no dimming)
"None"
Why this setting exists
Why this setting exists
When using Normalize length mode, all vectors are displayed at the same length. Without this setting, dimming would either:
- Not work at all (all vectors same visual length)
- Always show the same dimming level
current_raw_length) instead of the normalized display length, allowing you to see both consistent direction visualization AND magnitude feedback through color.vector_display_functions.gd:54-58
Constants
SHORTCUT
vector_display_settings.gd:5
DIMMING_SPEED_CORRECTION
vector_display_settings.gd:6
How Settings Trigger Redraws
The settings resource uses Godot’s built-inResource.changed signal:
vector_display_2d.gd:22
- Any
@exportproperty is modified (editor or runtime) - Godot automatically emits
changedsignal - Connected
queue_redraw()is called - Vector is redrawn on next frame with new settings
This automatic system means you never need to manually trigger redraws when changing settings - just modify the properties and the visualization updates instantly.
Creating Custom Settings
In the Editor
- Right-click in FileSystem
- Create New Resource
- Search for
VectorDisplaySettings - Configure properties in Inspector
- Save as
.tresfile
At Runtime
Duplicating Settings
Using
duplicate() creates an independent copy. Modifying the duplicate won’t affect the original or any nodes using it.Example Configurations
Debug Velocity
Rainbow Direction Indicator
Dimming Speed Indicator
Best Practices
- Share resources - Use the same settings across multiple visualizers for consistency
- Create presets - Save common configurations as
.tresfiles - Use dimming for feedback - Helps distinguish active vs idle states
- Rainbow for angles - Great for showing rotation or aiming direction
- Axes for learning - Enable
show_axeswhen teaching vector decomposition
Settings can be modified at any time without performance concerns - the smart redraw system ensures efficient updates.
