# Implementing a hook (Like pudge in Dota)

I'm coding a new game, which involves hooking.

Ive been testing a couple of ideas now and im quite stuck.

The player can throw a "hook" which fires away in the aimed direction, until it hits something, it will bounce on some obstacles and will return to the player if hitting other obstacles. While the hook is in the air, the player can move as he/she wishes, and hook will after a certain time be pulled back to the player.

I don't know if you guys have played pudge wars, but that is the kinda hook I'm after.

What do you think is the best approach in simulating this?

Should i save points a long the way?

Edit: Yes the bounce thing is a from pudge wars. And yes the length, not time, that is true!

-
Pudge's Hook doesn't retract based on time but on distance. – Luis Estrada Jan 28 '13 at 22:00
I don't remember it bouncing off walls either in Dota; this must be unique to Pudge Wars – Jimmy Jan 28 '13 at 22:08
For an example of what najk is talking about: youtube.com/watch?v=wAItR6y3kQw – Luis Estrada Jan 29 '13 at 1:38
Just do it. I don't think this question as it is can be answered. An equivalent question would be, I want to replicate x from game y what do you think the best approach in simulating this is? Should I try z? – Tony Jan 29 '13 at 15:01

Here's one approach to doing it. It's unlikely this is the approach Warcraft 3/Pudge Wars would use - more on this later.

1. Look into using parametric curves like Bezier. Given an initial set of points, you can have it construct a curve for you. Bezier (as an example) allows you to easily add more points if need be.
2. Start solving the curve via it's parametric equation. Do small steps of t, and add a vertex on each side of the curve. Keep track of your indices as well. You may need to draw this out on paper to visualize the first time around and do a few internet searches on doing it nicely, but it's nothing to fear. After this step, you have your geometry as it follows the curve. As the geometry bends you may need to add more points around these bends, otherwise it will look blocky. Again, all solvable using the information that something like Bezier gives you.
3. You can now texture this thing! If you want to have a pulling animation of some sort, you can play around with (u, v) offsets. Picking a good texture with an alpha map will go a long way to making it look eye catching. For this to work, you may want to have separate texture for the body - something like meat, and ending hook-like texture.
4. When it's time for the player to be dragged, position the player on the end of the curve and start moving them back along the curve.

Your end result should look something similar to this:

I watched the video Luis Estrada posted. Warcraft 3 modding community has learned a lot of neat tricks over the years on how to coerce WC3 engine into doing what they want it to do. This results in implementation-specific effects. However, you should be able to simulate the animation of the hook in that video by using #3.

This is a fairly standard approach to doing these effects. Ikaruga is one example where it uses neat texture offsets with alpha to create movement of rays.

-