by taniwha » Wed Sep 19, 2012 11:30 pm
What you want actually doesn't make physical sense. The code I gave you causes the wall to rob the beam of exactly the velocity component going directly into the wall (if you were to aim perfectly perpendicular to the wall, the beam would just stop dead). The reason the beam goes off to the side when aiming up but at an angle to the wall is because that is the direction of the player's aim relative to the wall.
It might be better to think of the player's aim forming a cone around the line between the player and the wall such that the line is perpendicular to the wall (the wall might not actually exist at the point the line hits the wall. ie, you might have to imagine the wall being extended far enough). The player's aim then has two components: one going towards (perpendicular to) the wall, and one going along (parallel to) the wall (radiating out from the above mentioned intersection point). Hitting the wall removes the perpendicular component. The only way for the beam to go straight up when hitting the wall when the player is aiming a little to the left or right is if there is something else there to stop the beam going to the side. There is nothing there to do so. If you want to use friction with the wall, then the beam would just stop dead as friction works in all directions (parallel to the wall).
Try it with a garden-hose on the ground (or a wall if you really want, but then you've got gravity getting in the way).