Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

In the Zelda games, there is an item called the hookshot. It is a small mechanical apparatus held in one hand that acts similar to, but not the same as the gun. When it is triggered, the hook at the tip of the item springs forward and an extending chain follows behind it. This chain is spawned when the hookshot is triggered and disappears when the hook is retracted. The chain is not visible beforehand, i.e, it is not spooled around any kind of cylinder and unspooled when shot.There are also other games where characters use grappling apparatus that can be made shorter or longer when a character is hanging from a specific point or pivot. Similarly, this grappling tether is created or hidden as needed to support whether the player wants to shorten or lengthen it.

My question is, how could one create an extending chain whose links are only visible when triggered and when retracted disappear from view? This chain does not need to necessarily interact with physics. I've thought of a couple of ways someone could create an effect like this, but I would rather see if there is a better known solution or implementation of this or a similiar effect before I dive in. Potential solutions could include:

  1. A particle effect between the base of the hook and the tip of the gun. This might be far better suited for displaying a non-physical, energy tether, but I am not as familiar with the particle system in Unity and I am curious to see if a chain link could be faked with a particle.

  2. Creating a chain link by link or section by section procedurally based upon the direction the hook was firing in and the distance between the positions of the gun tip and hook base. This seems like a more direct solution, but could have higher processing cost as the links are created on the fly and in rapid succession.

  3. Creating a chain that is hidden when not fired and is made to slowly appear when fired as the hook leaves the hookshot apparatus. This seems like the most likely solution, but I have little to no idea as to how it could be implemented.

I would not be surprised at all if there is a better solution that I didn't mention. I look forward to seeing what people suggest. Thank you.

share|improve this question

1 Answer 1

I recommend your second option, adding/removing links.

If option 1, using a particle system, is even possible, it is highly likely to be essentially reimplementing option 2 by twiddling the particle system from outside. You'll also likely have issues at the ends due to the particles being obviously different from the neighboring geometry. I've never seen a particle system trying to represent a solid object do a decent job of it.

Your option 3, a partially-hidden chain, is possible — I don't know if Unity can do it by default, but it's certainly something a GPU can support. Think of a "half-invisible texture" slid along the length of the chain and controlling the visibility of the chain surface (or an equivalent directly programmed in the shader).

However, I think your option 2, creating objects on the fly, is likely to be the way to go. Creating new objects isn't as unreasonable as you might think. Think about a game with non-hitscan projectiles: in a big fight you would have lots of temporary objects flying around. In fact, you could keep around a fixed set of chain link objects up to the maximum length and merely hide/show and position each one as needed - that should be very cheap.

Since you mention Zelda games, I'd like to point out the example of the pull-chains in the Arbiter's Grounds in The Legend of Zelda: Twilight Princess. There are several places where (due to sloppy positioning), you can see new chain links popping into existence at the wall when you pull a chain out or when it retracts. That is, they chose option 2, though specifically for a flexible chain.

All you need to do to avoid the visible glitch is to make sure the addition/removal is buried inside other geometry (in the case of a hookshot, inside the hand grip's model). Also, you can make a single model of several chain links to add/remove at once as long as it's short enough to fit inside.

Using individual links also means that you can add bending effects if you want — I wouldn't recommend trying to add simulated physics unless you want to focus on that, but you could have it appear to curve in flight, slacken when the hook hits something, or vibrate under tension — whatever looks good for its role in the game.

share|improve this answer
    
I think you're right about option 2 as far as it being the most likely to succeed. I've already written code to lerp a Gameobject to a clicked position along a line, which is indicated by a line renderer. I'll attempt instantiating game objects along that same vector and if it looks like a halfway decent solution I'll let you know. I want to try doing this procedural through code if only so that I can show its intended gameplay independent of art, but I have the sinking suspicion this is the kind of effect usually depicted using an animation on an art asset. –  Stampyturtle Jul 9 '13 at 1:36

Your Answer

 
discard

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.