I'm making a 2D shmup with XNA 4.0 and one of the weapons in the game that I want is a laser beam that follows a path or a series of points and will smoothly beam along the path.

How would I go about achieving this?

  • 4
    \$\begingroup\$ This is way too broad of a question. What do you have so far? Have you tried anything? Perhaps you have some code that isn't quite achieving the result you desire but almost? \$\endgroup\$
    – DomenicDatti
    Commented May 29, 2012 at 15:55
  • \$\begingroup\$ You've got to google around a bit and try it on your own first. SO is not in the business of hand-holding, sorry. \$\endgroup\$
    – SpikeX
    Commented May 29, 2012 at 15:56
  • 1
    \$\begingroup\$ Is gamedev.stackexchange.com/questions/29424/… what you're looking for? This question covers the 'bendy laser' that shows up in some shmups. \$\endgroup\$ Commented Jun 29, 2012 at 18:03

1 Answer 1


Try using a Queue of (x,y) coordinates. I don't know if you'll need to do it dynamically or at compile time, but you should be able to figure something out either way.

Are you wanting the laser to follow curves as well, or just connect the dots? If its the first option, you're gonna need to do some math too.

  • \$\begingroup\$ Yes I want the laser to follow a curve. I have been playing around with some code and I can make lasers go in a straight line just fine so far. \$\endgroup\$
    – user1424132
    Commented May 29, 2012 at 17:52
  • \$\begingroup\$ And does it need to go exactly through every point, or would a best-fit curve work? \$\endgroup\$
    – Phillip Schmidt
    Commented May 29, 2012 at 18:44
  • \$\begingroup\$ Also, do we know anything about the nature of the curve? Is it going to depend on user input? I.e, is the equation of the curve going to be ever-changing? If so, you're fairly screwed here without some extremely complex math. \$\endgroup\$
    – Phillip Schmidt
    Commented May 29, 2012 at 18:50
  • \$\begingroup\$ no it doesn't have to go through every point. And I have never here of a best fit curve until now. But i'm assuming that it would take the shortest path from start to end. \$\endgroup\$
    – user1424132
    Commented May 29, 2012 at 18:52
  • \$\begingroup\$ Kind of. It's calculated using what called the 'least squares method'. An explanation of that method would be out of the scope of this answer, and it too requires some pretty high-level math (at least in nonlinear situations). Last question: where are you getting the points from? Do you have an equation for them, or are you just coming up with them yourself? \$\endgroup\$
    – Phillip Schmidt
    Commented May 29, 2012 at 19:02

You must log in to answer this question.