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 MojopinStudios · Feb 04, 2013 at 10:15 AM · animation

Best approach for handling catching/throwing/bouncing of a ball

I am porting over some concepts from XNA to Unity. I am looking at a sport game which the player can pick up the ball, catch the ball, bounce and kick the ball. Now within XNA I added a bone to my rig specifically for the ball. So when the bounding box (collider) came in contact with the ball the animation would kick in and the ball model would be attached to the bone in the animation. Same thing with the likes of bouncing it, ball is attached to a bone in the animation.

This all looks fine, but I don't know if it is the best practice, plus it was difficult to release the ball from the bone until the end of the animation. When kicking the ball it should be unattached from the bone when it hits the foot, at a certain frame in the animation, and force applied to it. But I couldn't work out how to find that specific frame of animation, but I assume that was more my lack of knowledge at the time (4/5 years ago) rather than the inability to do it.

So my question is, what would be the best way to approach this? Is my method, of creating new bone in rig and attaching ball the best way forward or is there better method?

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 MojopinStudios · Feb 04, 2013 at 09:13 PM 0
Share

Has anyone got any insight into this problem? I don't know if I phrased it right but there is bound to be someone who has done something similar.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Pysassin · Feb 05, 2013 at 10:21 AM

You could use the physics engine to do all of that. Give the ball arigidbody wih a custom physics material and set its bounciness to max so that it doesnt lose momentum after the bounce for dribbling. Then if you kick it just un parent lower the bounciness and add some foward relative force.

Comment
Add comment · Show 7 · 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 Pysassin · Feb 05, 2013 at 10:23 AM 0
Share

You can also just use the animation you have for bouncing or whatever works the easiest just turn is$$anonymous$$inematic off while animating then when you want to kick the ball turn is$$anonymous$$inematic on and add the force. Either way physics will be helpful for ya

avatar image MojopinStudios · Feb 05, 2013 at 10:25 AM 0
Share

I was thinking about using the physics engine, but how do you set it to stay in the hands for a period, bounce just right so it comes back into the hands, that sort of thing? Is there any examples out there?

avatar image MojopinStudios · Feb 05, 2013 at 10:31 AM 0
Share

I posted that last comment and didn't notice your comment before that. Ok, I'll give it a go and see what works best. Cheers.

avatar image Pysassin · Feb 05, 2013 at 10:43 AM 0
Share

If you use physics to bounce lock the rotations and x z positions and make the ball a child of the hand. That way physics makes it go up and down and it always goes to your hand because it moves with it

avatar image MojopinStudios · Feb 05, 2013 at 11:12 AM 0
Share

Yeah, I'll probably stick with the bone animation. If the player was standing still constantly then the physics animation of straight up and down might work. But when the player is running, the bounce will need to go a bit further ahead and bounce back into the hands to look realistic. This will be easier done with just the bone animation. Cheers though.

Show more comments
avatar image
1

Answer by Loius · Feb 04, 2013 at 10:45 PM

That's the method I've used. It makes sense.

Unity animations don't have frames, they have time. Your specific frame occurs at:

if ( clip.time > (targetFrame/framesInAnimation) ) { // release 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 MojopinStudios · Feb 05, 2013 at 09:28 AM 0
Share

Cheers, I'll try to reimplement it this method for the time being, unless someone has a better idea?

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

11 People are following this question.

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

Related Questions

Can the animation editor create local rotational data? 3 Answers

Adding animation clips via script 2 Answers

Can I make animations snap to a frame? 1 Answer

How to select an animation clip by index number? 7 Answers

How to edit fbx animations? 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