Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by oppie85 · Apr 20, 2016 at 10:34 AM · physicsvr

SteamVR and Unity Physics; How to make it work?

Over the last few days I've been attempting to make a simple table tennis game using SteamVR and the HTC Vive. The idea seems simple enough; add a paddle gameobject to the controller, add colliders to the paddle and ball and it should all work itself out. But it doesn't, as the controllers are not Rigidbodies and their movement works separately from the Unity physics system. As such it creates issues like the paddle moving through the ball when the controller moves too quickly, or the velocity of the controller not mattering in the collision since its rigidbody's velocity is always zero.

One thing I've tried is to mark the object as IsKinematic and to match its position to the controller using MovePosition and MoveRotation on the paddle Rigidbody. I also turned on interpolation to make sure moving the paddle too quickly doesn't make it go through the ball. This sort of works, but with a huge delay; the paddle is always lagging way behind the controller - so this is not an option.

Another thing I've been trying is to implement my own physics code for the paddle, but in a way I feel like this shouldn't be necessary as the controller already tracks all of the same variables as the 'normal' rigidbodies do, such as velocity etc. I'm wondering whether there is a possibility for some kind of 'hybrid' collision, where I could plug the SteamVR controller's velocity, location etc. into the Unity Physics system.

Does anyone have any ideas on how I could approach this scenario?

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 Heemrad · Sep 09, 2016 at 03:50 PM 0
Share

@oppie85 - HI im currently having the same problem with my Vive game im trying to make. Ins$$anonymous$$d of using a picked up object eg. Ping pong paddle i want the controllers to act as the ping pong paddle but how will that work using Newton VR interactable item script? Especially as it requires the players to hold an item that uses this script. Im not to sure as this is my first ever Vive game and im not 100% familiar with unity.

How could i make it so that the Vive controllers model applys the correct physics to an inco$$anonymous$$g ball that can be hit away??

Please any assistance will be greatly appreciated

3 Replies

· Add your reply
  • Sort: 
avatar image
6

Answer by AntzyP · Oct 04, 2016 at 07:19 AM

As you've found, by making the paddle a child of controller object, its position is set by SteamVR and you don't get accurate collisions, and unity physics either doesn't work or works weirdly with it.

The simplest method I've found is to not make the paddle child of controller. Instead, keep the paddle separate as child of none, and join it with controller using a Fixed Joint with break force and torque kept to Infinity. This moves it using Unity physics engine and all physics interactions work perfectly!

Comment
Add comment · Show 2 · 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 chusmaverde · Dec 06, 2016 at 03:21 PM 0
Share

Thanks a lot for this, it was a really good advice. I tried using the Fixed Joint and everything now works smoothly. I didn't know about this feature till now and it is pretty useful, specially with this VR cases.

avatar image baptistegr · Dec 01, 2017 at 09:26 AM 0
Share

Thank you, this is a great advice :)

avatar image
0

Answer by oppie85 · Apr 22, 2016 at 08:40 AM

For anyone who has the same problem; this article provides a very good solution which is included in a free downloadable library:

http://www.vrinflux.com/newtonvr-a-free-physics-based-interaction-system-for-unity-and-the-htc-vive/

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 Spanky11 · Dec 08, 2016 at 08:44 AM

I had originally found a solution online that, instead of making the object a child of the controller, it kept it as a separate, non-kinematic object that tracked the position of the controller by dynamically changing the velocity so that it moved along with the controller. This worked, but the object was jerky, and lagged behind the controller. AntzyP suggests the better solution. Use a fixed joint. And you already have the code for this! Just check SteamVR_TestThrow.cs

Comment
Add comment · Show 2 · 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 pegnose · May 13, 2017 at 06:47 PM 0
Share

I know this thread is old but I don't understand the advice. I look into the throw example but as far as I understand I need two rigid bodes to link together. But the S$$anonymous$$mVR controller has no rigid body. And if I add one, my grabbing action won't work any more. And if I ad one to the model, it won't get displayed any more. I am a bit puzzled here.

EDIT: Ok, I understand now. I need to add a rigid body to the controller's model and make it kinematic. Otherwise it will fall down. I could also disable gravity for the rigid body, but then the mass of the grabbed object will pull it down. $$anonymous$$inematic seems the way to go.

avatar image chusmaverde · May 21, 2017 at 10:01 PM 0
Share

It has been awhile since I did this, but the answer by AntzyP using Fixed Joint worked perfectly. I would recommend checking it out.

Regarding the gravity, you do not work with gravity as it is controlled by the user and that would result in some weird behavior. If I remember correctly I tried using the "is$$anonymous$$inematic" option and did not work. Sadly I do not have a VR set anymore to double check.

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 can i attach a ragdoll to my vr controllers,attaching a ragdoll to vr controllers, ragdoll is behaving sparaticaly 0 Answers

Object movement choppy when picked up in VR 1 Answer

Can't move object in VR if it has children 0 Answers

[SteamVR] Drum physics 3 Answers

Revolver cylinder physics 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