Public Group

# Zelda style boomerang

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

## Recommended Posts

Hi, i'm making a zelda like game and was trying to implement a boomerang where u shoot it, it goes a set distance and then returns to the user. I can shoot the bullet out ok but just not sure on how to implement the above.

Any suggestions would be great. Thanks

##### Share on other sites

are you looking to just be able to have the boomerang come back to the player in a direct path? One "simple" way is that once you hit the maximum distance:

1) figure out the vector from the current boomerang position to the player

2) calculate the step towards them

3) move the boomerang that distance

this will make the boomerang seem kinda funky tho...it will look like its attached to a zip-line as opposed to a nice arching return...

just a thought

##### Share on other sites

The boomerang does look like its attached to a zip line in the 2d Zelda games if I recall correctly. First thing to do is store a boolean variable for the boomerang which says whether it is moving away or not, toggle it when it hits the maximum distance, or hits something.

##### Share on other sites

First, pick a point 'x' units away from the player. Have the object route toward that position. After it reaches that coordinate, change to route to the player's coordinates.

Perhaps something like this:

Boomeraing::DoMove()
{
if(!mHasReachedTarget)
MoveToward( mTargetPosition );
else
MoveToward( Player.GetPosition() );
}


MoveToward() would change the velocity of the object toward the target, and if it reaches close enough to the target will consider it hit.

By moving toward the player's new updated position each time, it will generate a nice smooth curve.

##### Share on other sites

yeah, frob explains much better what I tried to say.

just outta curiosity frob, doesn't this also depend on the boomerang velocity and how much the player can move in a single update? It seems like if the motions were too rapid, you'd get a stutter with the motion. I guess attenuating the velocity would take care of that tho?

##### Share on other sites

Awesome, thanks very much for the help everyone. I think I know what to do to implement it now.

##### Share on other sites

In general, without "real" physics you'd implement this sort of thing as a piece-wise algorithm, over a time variable 't' (time, ticks, frames, or whatever your game uses), for the first span of 't' units, you move toward the target destination, and then afterwards the boomarang moves toward the player (who might have moved from his initial position, or indeed still be moving).

For extra fun, you could give the boomerang momentum and not allow it to change direction too rapidly. Then the player can manouver to miss the boomerang and have it turn around and circle back towards him from the other side, hitting enemies all the while. This mechanic can be seen in the Windmill throwing star in the Ninja Gaiden games, and a skilled player could continually dodge its return, using it in interesting ways. I don't recal whether it was destroyed after hitting the first enemy or not, but it could be done either way.

Or if that mechanic doesn't fit, for another interesting mechanic, allow the boomerang to miss the player and fall to the ground on the same mechanics, but make the player pick it back up before using it again. This would have the gameplay effect of limiting the player's movement after he throws a boomerang, which would make the choice to use it or not carry an opportunity cost that makes things more interesting.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 28
• 16
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
634112
• Total Posts
3015580
×