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 SlySnave · Mar 30, 2012 at 10:12 AM · rotationangularvelocityps3

PS3 Move.Me : angularVelocity to local space

Hello guys,

I'm working with the PS3 Move.Me package for Unity3D developed by Xun Zhang and having some trouble wrapping my head around converting the angularVelocity - which is relative to the world space - into an angularVelocity relative to the local space.

What I have so far is this:

 public Camera cam;
 private float camDecelRate = 0.12f;
 private Vector3 camRotateVelocity = new Vector3();
 
 void FixedUpdate ()
 {
     //---pan the camera if the trigger is being pressed---
 
     //trigger is pressed (equilelant to isButton)
     if (psMoveWrapper.valueT[0] >= psMoveWrapper.thresholdT)
     {
         float xPan = psMoveWrapper.angularVelocity[0].x;
         float yPan = psMoveWrapper.angularVelocity[0].y;
         cam.transform.Rotate(new Vector3(xPan, yPan, 0) * Time.fixedDeltaTime);
     }
 
     //trigger just released
     if (psMoveWrapper.WasReleased(0, PSMoveWrapper.T))
     {
         float xPan = psMoveWrapper.angularVelocity[0].x;
         float yPan = psMoveWrapper.angularVelocity[0].y;
         camRotateVelocity = new Vector3(xPan, yPan, 0) * Time.fixedDeltaTime;
     }
 
     //trigger not pressed AND still decelerating
     if (psMoveWrapper.valueT[0] < psMoveWrapper.thresholdT &&
         camRotateVelocity != Vector3.zero)
     {
         Vector3 velocity = Vector3.zero;
         camRotateVelocity = Vector3.SmoothDamp(camRotateVelocity, Vector3.zero, ref velocity, camDecelRate);
         
         cam.transform.Rotate(camRotateVelocity);
     }
 }

Basically, the plan is that the camera will never move, but can be panned around by depressing the trigger and swiping the PS3 controller in a direction (similar to touch screens).

The trouble is (again) that the angularVelocity for the wand is relative to the world space, but I need it relative to the local space. Also, the wand orientation (what I think I would use to translate the angularVelocity to local space) is in world space.

I know this is referencing an external package that people may not be familiar with at all, but any insight would be greatly appreciated :)

EDIT: I've just noticed this question and I'm not sure if there is such a thing as "local angular velocity", but basically what I need is for the same result to happen in both of these cases:

  • I am facing the PS3 Eye with the controller pointing forward ([0, 0, 0] rotation) and swipe downward ([-x, 0, 0] angularVelocity) to rotate the camera upward (which functions right now)

  • I am facing to the left of my previous orientation (with the PS3 Eye 90 deg. to my right) with the controller pointing straight ahead of me ([0, +90, 0] rotation) and swipe downward ([0, 0, +z] angularVelocity) to rotate the camera upward (which doesn't function right now obviously because when I turn, the swipe affects the z axis)

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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Move an object toward an angle in 2d space 0 Answers

CharacterController doesn't rotate on my script... 1 Answer

How to make Main Camera shake correctly when getting attacked? 1 Answer

player rotation from the top with mouse position? 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