Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Probably everyone is familiar with all kinds of visual node based programming tools like HLSL editor in Visual Studio 2011 or UDK engine Kismet/Material editors. My point of interest are the connectors between the nodes. Basically those are implementation of Bezier Curve algorithms. Those are not hard to put into code.

How I make each connector line bend into right direction and with the right angle when it is being connected between two points not laying on the same line?

share|improve this question
I guess that question is better suited for stackoverflow – bummzack Jan 9 '12 at 10:04
Yeah ,I think I will post it there.Tnx. – Michael IV Jan 9 '12 at 10:07
up vote 6 down vote accepted

Start with something simple. Use cubic bezier curves (2 control points), with the control points directly pointing out from the control nodes by some fixed distance. That should be good enough.

share|improve this answer
You can also use cubic Hermite splines, where you directly specify the endpoints and the tangent vector at each endpoint. (They are mathematically equivalent to Bezier curves with the control points placed as you described.) – Nathan Reed Jan 9 '12 at 17:26
@NathanReed Doesn't the Hermite spline run through the control points? That would make it actually less suited imho. – bummzack Jan 9 '12 at 21:10
@bummzack A Hermite spline has two endpoints (which it touches) and lets you directly specify the tangent vectors at those endpoints. A Bezier spline likewise has two endpoints, but shapes the curve by using two additional control points that it doesn't necessarily touch. You might be thinking of Catmull-Rom splines, which do run through all their control points (and are internally a set of Hermite splines with the tangents calculated based on neighboring control points). – Nathan Reed Jan 9 '12 at 21:28
I am using Flash Player API .It has got a built in cubic bezier.So to construct one is not a problem.The problem is to adjust its curve when you actually manipulate only the end point of the connector.Think of it this way:The start point of the connector line is connected to a node at x:100,y:100 .The endpoint is connected to the next node at the point x:500,y:400 so as you can imagine the curve should adjust itself to a sinusoidal bent for this position.Yeah I can think about all kind of trig solutions but I thought may be anybody knows some specific API that supplies all this . – Michael IV Jan 10 '12 at 7:34

I would personnaly use a cosinus. Why bother with a complicated and costly bezier curve ?

share|improve this answer
If the connectors are always horizontal, then a scaled cosine curve would actually be a pretty good and simple solution if the connections always go from the right side of the left node to the left side of the right node. Trouble is, often times you will drag nodes around so that this is not the case. – Nathan Reed Jan 9 '12 at 18:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.