you can make the laser beam length not be greater then distance from original point of creation towards x y of the enemy, so if it hits the enemy its going to stop to its center position as length, if enemy will come towards you or go away the laser will grow bigger or shrink!
wep x,y is the original point of the laser from the weapon i guess if u have any!
set width distance(wep.x,wep.y,enemy.x,enemy.y) see if that helps
if u have enemys and solids in one familly you can switch enemy.x,y to familly name .x ,y