# Hookshot chain problem

I’m make a platformer zelda fan-game, and im trying to implement a hookshot, but i can’t figure out how to do the chain. I was thinking there was a way to do this with a shape-painter, or a tiled sprite, but i’m not sure.

I don’t play Zelda so I don’t know what a hookshot is, but…
Tiled Sprite sounds suitable. You can make the chain’s width by finding difference between the hook’s tip and the base. Like
`hookTip.X() - hookBase.X()`
Do that for every frame the hookshot is active and make sure the chain’s X position is same as hook’s base.

You could use a shape painter to draw a line between a point on your character to a point on the hook. If you wanted contrast then you could draw a darker line first of say 5 pixels thick and then with a lighter color of say 3 pixels.

I’m sorry, I forgot to clarify what a hookshot is, cat, but it is a little gadget that you can shoot, it will launch a “hook”(it looks more like an arrowhead) attached to a chain, and you can shoot it in any direction. And Keith_1357, That would work, and I know how to do it, but I’m looking for a way to have the chain sprite I have.
I’ll put a gif of the base game without a shape painter so you know what im talking about as soon as I’m able

If you want a rope/chain texture, you should probably use a tiled sprite indeed.

With a tiled sprite, the concept would be.

Height = image height.
Width = distance between base of item and hook
Angle = angle between base and hook
Position would be the center point between the base and hook. I don’t know the best way to calculate this. Maybe just the average of the locations. (X1+X2) * .5

Maybe, there’s a simpler way. Maybe, physics joints(s). Maybe, a panel sprite. You could have all of the parts of the shothook in one sprite.

I like the idea of joints but also the control of things with a formula.

To test the concept, I’d just use 2 draggable sprites and see what technique aligns another sprite between them.

You can position the hook using [position and object around another using the weapon base as the [center] object. You can then change the distance using a tween.

Edit:
This is how I did it. It still needs tweaking but it shows my concepts. Press space to extend.

doug13579/Grappling-hook-in-Gdevelop (github.com)

3 Likes

THANK YOU SO MUCH!!!
I would never figure this out by myself!
the example link you sent demonstates it perfectly

2 Likes