debug / hair / node_2d.tscn

Diagram

Diagram

Overridden virtual functions

_ready

$Hair
func _ready() -> void:
	positions.clear()
	for i in range(SEGMENT_COUNT):
		positions.append(global_position)

_process

$Hair
func _process(delta: float) -> void:
	if positions.is_empty(): return
	positions[0] = global_position

	for i in range(1, SEGMENT_COUNT):
		var target = positions[i-1]
		var diff = positions[i] - target
		if diff.length() > MAX_DISTANCE:
			positions[i] = target + diff.normalized() * MAX_DISTANCE
		positions[i] = positions[i].lerp(target, LERP_SPEED * delta)

	queue_redraw()

_draw

$Hair
func _draw() -> void:
	for i in range(SEGMENT_COUNT - 1, -1, -1):
		var r = BASE_RADIUS * (1.0 - float(i) / SEGMENT_COUNT * DECREASE_RATE)
		draw_circle(to_local(positions[i]), r + OUTLINE_WIDTH, Color.BLACK)

	for i in range(SEGMENT_COUNT - 1, -1, -1):
		var r = BASE_RADIUS * (1.0 - float(i) / SEGMENT_COUNT * DECREASE_RATE)
		draw_circle(to_local(positions[i]), r, color)

Instantiators

Caution
No other scene instantiate this scene.

Scene Tree

Signal Connections

Note
No signal connections.

Properties

Table 1. Root properties
Name Value

position

Vector2(-25, 5)

scale

Vector2(6, 6)

Table 2. $Hair properties
Name Value

position

Vector2(5.3333335, -0.3333335)

lerp_speed

15.0