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 /
avatar image
0
Question by SteenPetersen · May 05, 2019 at 09:38 AM · camera rotateeuleranglesangularvelocityangleaxis

AngularVelocity/Velocity relative to a CameraRig (VR) - Throwing Objects wrong direction

Hi,

im in a bit of a pickle. I am working on trying to make objects that I release from my hand in VR adopt the correct velocity and angularVelocity of the controller so they feel correct. This is a simple matter of tracking the controller angularvelocity and velocity and passing it to the opbject upon release:

 rigid.velocity = controller.currentVelocity;
 rigid.angularVelocity = controller.currentAngularVelocity;


However, and here comes the kicker, I also have a locomotion system that happens to rotate the CameraRig with regards to the head of the player and after doing so these values are all wrong and shifted with regards to the cameraRig as so:

 cameraRig.transform.RotateAround(headsetCamera.transform.position, Vector3.up, -(headsetCamera.transform.eulerAngles.y - lastHeadRot.y));
 lastHeadRot = headsetCamera.transform.eulerAngles;


That's basically it, If I use other forms of locomotion angularVelocity gets set properly and works fine, but after shifting the world with the above code it messes up ther calculations entirely. Im wondering what I can do about this. Any suggestions?

Thank you for your attention.

@aldonaletto

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

2 Replies

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

Answer by SteenPetersen · May 14, 2019 at 06:13 AM

I solved this finally, so I thought I would add the solution here.

Instead of using this code to throw objects:

  _rigid.velocity = controller.currentVelocity;
  _rigid.angularVelocity = controller.currentAngularVelocity;


I used:

  _rigid.AddForce(controller.currentVelocity);
  _rigid.angularVelocity = controller.currentAngularVelocity;


this solved the issue and the objects now fly in the expected direction no matter what the roation of the parent is.

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 marcoszr · Nov 29, 2021 at 05:31 PM 0
Share

Hello!

I'm new to VR development so maybe this is a dumb question but, how do access to controller.currentVelocity? I mean, how do you obtain the "controller" object?

Thanks!

avatar image
0

Answer by wyatts · May 11, 2019 at 12:02 AM

It's seemingly simple, but there are some very complex formulas that can go into realistic feeling throws. Take a look at the SteamVR throwable scripts and you'll see what I mean.

In response to your issue you'd need to get the velocity of the tracked object in local space. Depending on how you're doing this you might have to calculate the velocity manually. Or if using SteamVR you could reference the SteamVR_Behaviour_Pose.cs script and this method: public Vector3 GetVelocity() { return poseAction[inputSource].velocity; }

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 SteenPetersen · May 11, 2019 at 12:08 AM 0
Share

Hey thanks for the input, Im making my own framework so im not using S$$anonymous$$mVR or oculus or anything building everything to work native with Unity.

As it is now I am already fetching the angular velocity and velocity of the controllers from the tracked nodes (ref).

avatar image wyatts SteenPetersen · May 11, 2019 at 12:17 AM 0
Share

In that case you'd want to calculate the velocity manually using transform.localposition ins$$anonymous$$d of the apparent default of worldspace. $$anonymous$$aybe this is unfounded, but my only concern with that is the further away you get from raw input the more room for issues - for example different controllers might not translate the velocity calculations the same.

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

106 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to rotate camera on sine wave. 0 Answers

How to rotate my camera? 2 Answers

How can I limit the player's camera to move to the edge of the map centering it on the camera? 0 Answers

Transform.Rotate() rotation about one axis also rotates about the other axes 1 Answer

AngleAxis or Lerp: change both rotation and speed? 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