Skip to content

Instantly share code, notes, and snippets.

@regakakobigman
regakakobigman / raybounce.gd
Created December 28, 2019 19:57
Bouncing rays in GDScript for lasers or beams of light
# Try passing in randf() * x for distance_from_surface or angle_adjust to get some slight randomness
func bounce_rays(
space: Physics2DDirectSpaceState,
initial_pos: Vector2,
initial_dir: Vector2,
count: int,
length: float,
exclude:=[],
distance_from_surface: float = 0.0,