Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Zelda style boomerang


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Lickatoad   Members   -  Reputation: 118

Like
0Likes
Like

Posted 21 February 2013 - 06:31 PM

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


Sponsor:

#2 IkarusDowned   Members   -  Reputation: 291

Like
2Likes
Like

Posted 21 February 2013 - 06:36 PM

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



#3 Paradigm Shifter   Crossbones+   -  Reputation: 5440

Like
2Likes
Like

Posted 21 February 2013 - 06:41 PM

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.


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#4 frob   Moderators   -  Reputation: 22783

Like
4Likes
Like

Posted 21 February 2013 - 06:42 PM

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.


Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.


#5 IkarusDowned   Members   -  Reputation: 291

Like
1Likes
Like

Posted 21 February 2013 - 07:02 PM

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?



#6 Lickatoad   Members   -  Reputation: 118

Like
0Likes
Like

Posted 21 February 2013 - 07:28 PM

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



#7 Ravyne   GDNet+   -  Reputation: 8193

Like
1Likes
Like

Posted 21 February 2013 - 09:33 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS