# Move forward according to step size
tp @s[tag=basicgunray] ^ ^ ^0.5
tp @s[tag=plasmarifleray] ^ ^ ^0.5
# TEST
execute at @s[tag=basicgunray] run particle smoke ~ ~ ~ 0 0 0 0 1 force

# Check for collisions with entities
execute positioned ~-0.99 ~-0.99 ~-0.99 if entity @e[tag=hitable,dx=0,scores={invulnerable=0}] positioned ~0.99 ~0.99 ~0.99 if entity @e[tag=hitable,dx=0,scores={invulnerable=0}] run tag @s add hitEntity

# Check for collisions with blocks
execute unless block ~ ~ ~ #ray_demo:ray_permeable run tag @s add hitBlock

# Decrease the number of steps remaining
scoreboard players remove @s steps 1

# Recurse until we hit something or run out of steps
execute as @s[tag=!hitEntity,tag=!hitBlock,scores={steps=1..}] at @s run function ray_demo:ray/move
