Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by tabsdmax · Mar 02, 2013 at 03:17 AM · physicsmathf

Ball hitting physics?

Hello,

I have been using Unity for a few weeks, and have begun to script my own small baseball game. It consists of just an automatic pitch and the player will have to hit it by clicking the mouse at the right time. To break it down.

  1. The balls co-ordinates are contained in variables.

  2. The user clicks when the ball is close.

  3. If the cursor location on click is close to the ball (I use mathf.clamp to compare cursor location to the co-ordinate variables).

  4. A hit is registered. Velocity is added to the ball relative to the bat used.

For now I want to add more realistic hits to the ball. I plan to do this with multiple mathf.clamp scripts, adding differing velocity and torque to the ball based on where the click was in relation to the ball.

Before I start this very long process, I would like to know if there is an easier way to add more realistic ball paths when the ball is hit?

  • hope I have explained everything clearly. I am still quite new with Unity and I am not looking for script examples, just other possible methods. Thanks for any help!*

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robertbu · Mar 02, 2013 at 05:39 AM 0
Share

A couple of musings:

  • Rather than apply force by hand, I wonder how well it would work if you allowed the ball to hit a collider. The collider does not have to be visible. A sphere or a capsule might work. The collider could be stationary or you could move it forward to simulate the hit. If necessary, just after they lose contact, you could magnify the velocity. You could size the collider appropriate to how "wild" you want the hits to be.

  • With the angular velocity and axis of rotation, you can calculate the vector for applying a curve force. Then you can apply a small amount of force each Update() to that vector to get the ball to curve. This can be used for both pitches and hits.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to control easing in Mathf.smoothDamp? 1 Answer

MAKE A LEVITATING PLATFORM REACT TO A PLAYER'S JUMP? 1 Answer

What is the best way to map the curve of a jump? 1 Answer

Knockback and Launch Angle 1 Answer

My Motorcycle Physics Need Some Customization 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges