Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
1
Question by Tifoo · Jun 15, 2016 at 06:21 AM · physicsvrball

Hit ball with racket

Hi,

I'm developping a VR game with HTC Vive, and i'm starting by making a ball interact with a racket. The ball is a Sphere (radius 0.1) with a rigidbody. The Racket is a cube, in a rectangular shape : x:0.2 y:0.2 z:0.03

The ball interact with the racket quite well at slow speed, but when I move my racket faster, it goes through..

I tried to tweek some physics value : Fixed Timestep to 0.01 (1/90 for the Vive) Solver Iteration : from 6 to a lot a values, even 100 (just for test purpose), it helps a little but not too much.

I also tried to add the DontGoThroughThings scripts but it does not help

I changed the collision detection to "Continious Dynamic" for both and try changing Interpolate to the interpolate and extrapolate..

Nothing will do, How should I achieve this? I do not want to code that (should I?), because it has to feel very realistic (VR..) when my ball is on my racket. I assume Unity should be able to handle that?

Thank you

Comment
Add comment · Show 8
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 Brijs · Jun 15, 2016 at 09:39 AM 0
Share

To move and rotate the ball and rocket use rigidbody methods only ins$$anonymous$$d changing transform. $$anonymous$$eep collision detection to "Continuous Dynamic" and Interpolate to "Interpolate" That should solve your problem

avatar image Tifoo Brijs · Jun 15, 2016 at 09:51 AM 0
Share

Hi Brijs,

Thank you for your answer. I do not used transform or anything, because it is Virtual reality, I use the S$$anonymous$$mVR plugin and attach a racket to my Touch Controller. It follows the movement of my hand. The ball has a rigid body and react to my racket movement, it works well at low speed but when I speed up, it goes through. I took a look to newtonVr http://www.vrinflux.com/newtonvr-a-free-physics-based-interaction-system-for-unity-and-the-htc-vive/ and it seems running quite smooth, I'll try it. But it's a "black box" solution, I would be happy to know how to handle this issue by myself.

Another article I just found, where they adress my issue of balls going through racket ! http://www.vrinflux.com/newton-vr-physics-based-interaction-on-the-vive/

avatar image hexagonius Tifoo · Jun 23, 2016 at 07:53 AM 0
Share

Brijs is right. As you said "I use the S$$anonymous$$mVR plugin and attach a racket to my Touch Controller", this might be the cause for your problems. Depending on the plugin, there's a good chance, that the Touch Controller is not moved in the physics time step. Whatever is attached to it will fail using any good collision.
Either look for a setting in the plugin that lets the controller change it's Unity internal positions in the physics update loop, OR, which I think is more the case, make the racket FOLLOW the controller by using $$anonymous$$ovePosition and $$anonymous$$oveRotation. It might even be worth to do this with the colliders only and keep the visuals updated the way you do. A question of tuning I guess.

Show more comments
avatar image Tifoo Brijs · Jun 15, 2016 at 06:38 PM 0
Share

Newton VR does not help in my case. I'll will try to code something like that : I detect contact on my racket (with raycast), and I'll apply a opposite force on the ball based or my current racket velocity, don't know if it will feel realistic ..

avatar image Tifoo Tifoo · Jun 16, 2016 at 07:57 AM 0
Share

I can't do that actually :(, as it changes the transform of the object held, but does not apply force.. I'll will tweak NewtonVR to make it more responsive to fast movement if I can..

avatar image Kmausser · Jun 22, 2016 at 08:22 PM 0
Share

Did you ever figure this out? I'm having the same problem. I'm using stonefox's VRT$$anonymous$$ scripts which are similar to newton. alt text

Videos of what my golf game looks like with this frustration:

https://youtu.be/_QZBl3zHNf0

https://youtu.be/2zdHsPZBQ7Y

avatar image Tifoo Kmausser · Jun 23, 2016 at 07:34 AM 0
Share

Unfortunately not.. I'm not sure there is an "on the go" solution with the unity physics.. For now, I change my $$anonymous$$d and started a new game with no high velocity physics needed, that's a shame :(.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by BostonLeeK · Aug 06, 2018 at 11:45 AM

The post is old but If somebody will stuck on this: The only one way to make it working nice is to make collision detection and changing velocity of the ball without rigidbody on the racket.

So, how i made it:

1) create empty prefab (name it RacketController for example) and give him box collider with a trigger and rigidbody with cinematic, like a child of this object i add Racket with only box collider. (I need parent cose i must to change the child visible or not for type of controller tracker or joystick)

2) Add a script to RacketController that change Rigidbody position (important that it is rigidbody) to position of my right controller

3) Add checking velocity of the rigidbody and saving it to variable

4) Create a ball with a rigidbody and sphere collider

5) Create a script and add it to the ball where i cheeking the collision and use such formula

 direction = Vector3.Reflect(lastFrameVelocity.normalized, collision.contacts[0].normal);
 this.GetComponent<Rigidbody>().velocity = direction * speed;

where lastFrameVelocity is the velocity of the ball on starting collision and collision is the object that ball is touching. And after i just add new velocity to the object. And i the object name is Racket for example i get the velocity from RacketController and multiply it with the ball velocity.

 float addForce = RacketController.GetComponent<TrackerFollow>().RacketVelocity.magnitude;
 speed += addForce;

And i remove physics material from the ball to make all work done by script.

The final result not best but now the ball not crossing the object through. There need some working with a script to make force on ball more realistic but it work.

Hope for someone this post will be useful. And this is result on video: https://youtu.be/F2_PllPlV4M

Comment
Add comment · 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
0

Answer by vkapoor · Jan 23 at 01:33 PM

The video link does not work anymore. Can you please post again? I am wondering how you check the velocity of a Kinematic Rigidbody in step 3 above. Do you calculate it based on transform.position?

Comment
Add comment · 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

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

7 People are following this question.

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

Related Questions

Racquet in VR, doesnt hit the ball, and sometimes it "sticks" to the ball. 1 Answer

Rotating an object with VR controller 1 Answer

Restricting Rotation Of an Object in VR 1 Answer

Trajectory of a Ball 1 Answer

Third person game hit a ball 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