Need a working example of a Segment Collision Shape 2D

Godot Version

Godot version 4.2.1

Question

Anyone have a working example of instantiating a static object with a collision shape 2D (set to segment)? The docs talk about two vectors, a and b, equating to the positions of the two endpoints but I haven’t found a reference to them that works.

var static_body := StaticBody2D.new()
add_child(static_body)

var collision_shape := CollisionShape2D.new()
collision_shape.shape = SegmentShape2D.new()
collision_shape.shape.a = Vector2(42, 42)
collision_shape.shape.b = Vector2(1337, 1337)
static_body.add_child(collision_shape)
1 Like