#Making generated lines?
1 messages · Page 1 of 1 (latest)
Here is a quick reference for what I am talking about, is there a way in my sprite sheet i can say that these points should be the beginning and end of the lines
the power lines will be randomly placed, so they need to be connected and i dont want to make a sprite sheet of lines
You can use a draw_line() call in a node's _draw() function.
Altho you may want a separate node to draw the lines instead of leaving it to the pole (or at least have the pole use a different node to define where the points go)
You can either manually define each position as a pair of coordinates or use plain Node2Ds like "WireConnectionPoint" and use their position.
extends Node2D
class_name WireConnector
##Set this to the other end. Leave it empty for the receiving end.
@export var target_connector: WireConnector
##Used to draw the wire
func _draw()
##Do not draw anything if there is no target.
if target_connector == null: return
var target_point: Vector2 = to_local(target_connector.global_position)
var width: float = 2
draw_line(Vector2.ZERO, target_point, Color.BLACK, width)
You can also programatically look up every connector or even define a coordinate in the pole itself and use that point.
There's plenty of ways to do this.
I am new to Godot so i didnt know there was a thing called draw line lol
There's a bunch of draw_* functions.
this is my layout for "everything" i need to work out
and how im going to determine which one connects to which
i might just see if the Y values are different, if they are then i check which ones closest on the nearest Y value