# Draw Lines [Help]

This topic is 2765 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello Guys,
I want to connect 2 models with lines and make them behave like in this video game:

How do i do that ?
I realy don´t know where to start.

##### Share on other sites
Never played the game, but behavior can be pretty specifically made for certain scenarios. Drawing the lines is not really that hard though. An entities' position is basically represented with a vector (x, y, z position in space) and you can simply draw a line between the 2 positions.

As for the behavior itself, I don't really know what you want to do, but if you for example want the characters to not be able to move a certain distance from each other, you can simply do (position1 - position2) and check for the distance.

I think it would be wise to look into vector and matrix math and you will figure certain things out you might want to do.

##### Share on other sites
The main problem ist, that i want the lines to move like the ones floating in the video when a character moves.

##### Share on other sites
if you mean the lines around Gaara, you might try and use bezier curves:http://en.wikipedia.org/wiki/B%C3%A9zier_curve. They provide you pretty much the same effect.

move the *control points* of the bezier curve around a bit using a periodic function such as sin() or cos() ( because the values of sin and cos range from -1 to 1, the lines will move both up and down). Try that and check if it works. You might be in for some heavy tweaking though

##### Share on other sites
Hidden
Ah right, I misread and thought you want the behavior of the characters. My bad!

Yeah you should go with what bollu

says, probably the best way to go.

One alternative (and more complex) way to achieve that effect is to use Inverse Kinematics on the line connecting the character's finger to the back of the puppet.

Here is a video showing the process.

##### Share on other sites
Looks like maybe a string simulator, although somewhat tricky since the "target length" of the string is constantly changing to keep it pulled fairly tight between the two characters, but loose enough to boing up and down nicely. I think it should work just fine, to change the stretch constant for a string every frame (not so constant now, are you? )

Check out this site, for a simple way to do string simulation http://freespace.vir...ls/m_string.htm
I wrote a little demo for gameboy advance based on that article a long time ago, which can be found here:
http://deku.rydia.ne...ram/sproing.zip
http://deku.rydia.ne...oing-source.zip

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 12
• 30
• 9
• 16
• 12
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!