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 user-12306 · May 02, 2011 at 07:23 PM · addforcegolf

Adding Loft to a ball in a 3d golf game within Unity

Hi guys,

As a team of 5, we're creating a golf game as part of our second year University project. Following tutorials and editing them where needs be, we currently have our ball rolling and hitting objects, using collision physics. Unfortunately, we need to add loft to ball upon a hit from a club.

Would anyone be able to help us or guide us in the right direction as to how we can do this? Unfortunately, we are on a break from university and are currently unable to talk to our tutors.

We appreciate your help

Thanks

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 AngryOldMan · May 02, 2011 at 11:02 PM 0
Share

Are you studying at Leeds $$anonymous$$et?

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Xedfire 1 · May 02, 2011 at 07:34 PM

If your golf ball has a rigidbody, you can use rigidbody.AddForce(...). Go HERE for more info. Hope this helps, and good luck!

....

EDIT:

I just thought that I would edit my answer to provide extra information. So, the way that I would do what you're asking for would probably be...

  • Make a new script.

  • In that script, Use an OnCollisionEnter function to know when the ball is hit. Look at THIS tutorial for more info. Remember to check if you are actually colliding with the golf club.

  • In that OnCollisionEnter function, use rigidbody.AddForce(). See THIS.

  • Next, save your script and attatch it to your BALL.

Comment
Add comment · Show 1 · Share
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 user-12306 · May 02, 2011 at 08:12 PM 0
Share

Is there any way I could send you the code and you could possible advise us where it is to be placed? I know this sounds so cheeky, but we are desperate right now :)

avatar image
1

Answer by Chris D · May 02, 2011 at 08:24 PM

//pseudocode

if(hit){
     rigidbody.AddForce(directionYouWantItToGoAsAVector3
                        *magnitudeOfForceToApplyAsAScalar)
}

put it in your update function, attached to your ball. You'll still need to write the program. Check out the documents and come back to ask focused questions if you have problems.

Comment
Add comment · Show 3 · Share
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 user-12306 · May 02, 2011 at 08:41 PM 0
Share

Like I said, we are very short of time so i apologise for my unfocussed questions.

avatar image Chris D · May 02, 2011 at 09:21 PM 0
Share

it's just a matter of explaining a little clearer what you want. How are you handling the club? is there an animation that needs to play out? did you want the ball to actually be impacted according to the unity physics engine or did you want to have fine-tuned control from some sort of user interface. Any details you can add to the question will help people give you better responses.

avatar image Xedfire 1 · May 02, 2011 at 09:41 PM 0
Share

Yeah, I assumed you had a moving club.

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

No one has followed this question yet.

Related Questions

Addforce after Instantiate 2 Answers

Add Force Problem 0 Answers

Force Help 0 Answers

Making knockback smooth instant of instant 0 Answers

Physics are different in Build and Editor 0 Answers


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