I'm using a raycast with a line2d to show my ball's predicted trajectory.
Sometimes it works flawlessly:
Other times, the reflected line does not show, but raycast does:
I've printed out the coordinates for when the collision happens, and it all checks out. The line just does not get drawn at random angles.
Here is my section of code for bouncing raycast and drawing the line:
# Ray 1 collision (first bounce)
var lineCastColPoint = lineCast.get_collision_point()
var lineCastColNormal = lineCast.get_collision_normal()
var incoming_direction = lineCastColPoint - lineCast.position
var outgoing_direction = incoming_direction.bounce(lineCastColNormal)
# Ray 2 collision (second bounce)
lineCast2.position = lineCastColPoint
lineCast2.cast_to = outgoing_direction
var lineCast2ColPoint = lineCast2.get_collision_point()
line.add_point(lineCastColPoint + outgoing_direction)
Any suggestions? Thanks in advance!!