Jump to content
  • Advertisement
Sign in to follow this  
CDR2003

How to throw a ball by the mouse??

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Excuse me, my English is not very good. I'm writing a demo about throwing a 3D model. I wanna use the mouse to drag the ball. And when I make my mouse button up, it should be thrown away. Just like the game Nintendogs from Nintendo on NDS. How can I do that?

Share this post


Link to post
Share on other sites
Advertisement
multiply the mouse movement delta when the left button was released by some constant. Store that velocity in your ball's object.

Share this post


Link to post
Share on other sites
I'm not aware of the specific game... Do you want this to look as realistic as possible?
If yes, you will have to set up a dynamics simulation (simulate real world physics) with forces/torques etc. to animate your scene. Then you should add a spring constraint on the objects you click. So long as the mouse button is down, this will effectively try to move the object closer to the cursor (the actual point implied by the cursor in your 3d scene). When the mouse button is released, just cancel the constraint and the simulation will handle the rest, since the ball will have gained momentum.

You'll have to implement a basic physics engine and collision detection/response.
I'm sure you'll find lots of material around. If you have any questions about a specific part of this, just ask.
I assumed that you will want to try this "real physics" approach. Anything else will be a hack, and probably a bad one since you want this in 3d.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!