Grappling Hook - how to?

Topics: User Forum
May 17, 2010 at 9:48 PM
I've been toying with Farseer for a game prototype and I'd like to create a grappling hook. I know that it's been done before (especially from the videos in this thread) and I've tried to follow the information in that thread, but I'm still not getting satisfactory, or even working, results. Does anyone have any code that they could share that demonstrates this? Thanks!
May 18, 2010 at 7:38 AM
Edited May 18, 2010 at 7:42 AM

Hi there. Could you explain how did you implement your rope and which issues you have? Just to figure how to help you :)

In my case, the best method I've found so far, was to attach each link with a revolute joint or a spring joint with its neighbour, and then attach the two ends of the rope with a springjoint. If you see that your rope waggles, try to separate the links a little bit or make them a little heavier, or both. This works with Farseer 2.1 and Farseer 3.0.

BTW: I guess you are the same UberGeekGames from the Manly Game for Manly Men. It looks quite funny I hope you finish it soon, it looks like a third person version of a "Aaaahhh, a Reckless Disregard for Gravity" in the mountains (and bouncing in them) :)

May 18, 2010 at 10:54 AM

The basic idea is that you trace a ray in the direction you wish to shoot and find the closest geom. You then create a SliderJoint (Farseer 2) connecting your player and the geom. You can also use lot's of bodies and joints to make the rope, but I'd suggest getting it working with a single joint first, as it's easier to see where you went wrong.

What exactly were you having trouble with? Maybe post your code and we might be able to see where you're going wrong.

May 18, 2010 at 4:53 PM

Here's what I have so far: http://xna.multigan.com/pastebin/?page=view&id=1274197578 the code is very poorly laid out as I was just playing around with the samples and this grew out of it. Basically it creates a chain object from the advanced sample at the player's position when you hit a key, and moves the player's position to the last link in the chain.

The two problems are that 1) I can't get the chain to feel very rope-like, and 2) the 'player' object goes flying off at a crazy angle when I remove the chain. I haven't even begun looking at the

I have a feeling that I've been going about this the wrong way - I'll try it again later, following that thread more closely this time and your tips. :D I was hoping that someone had a sample laying around or that I missed a tutorial somewhere so that I wouldn't need to duplicate its functionality, but I guess this'll be a good way to get used to Farseer.

 

@pnikosis: yes, I'm one and the same. Glad you liked TMG - it's in peer review so it should be out soon! :)