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 /
  • Help Room /
avatar image
0
Question by arkea · Oct 29, 2015 at 10:38 AM · camerarotationvrmovingrotation axis

I have some Rotation problems

Hi everyone !

I wish someone could help me because if not i'm stuck forever :(

I'm making a Vr App and i've some probleme for the rotation of my object :

I've made a capsule for my character and I use the CardboardAdapter prefab. I didn't made the capsule a child or a parent of the camera because i never succeed to update the rotation of the Capsule(which have the script making going forward) by those of the camera and so i couldn't going where i was looking.

So i have two distinct object :

  • the MainCamera (with CardboardAdapter as a child)

  • and my Capsule

I've wrote those two scripts :

  • One in JS which make the capsule taking the rotation.y of the Camera)

  • One in C# which make the Camera following the capsule transform.position with an offset

But i have some problemes it doesn't work for all the angles so i told myself i juste have to log the rotation.y of both objects on the game screen in realtime for seeing what's happening but it always log the same so there is not the problem here :/ And when i make the rotation of the CardboardAdapter differently before making the simulation, it make the capsule following the rotation of the CardboardAdapter more and more slowly( for example MAin Camera set to 180° and capsule to 50°, i launch simulation and directly the capsule goes to 175 and very slowly goes to 180°)

So i hope someone can understand my so good english :/ (Sorry I'm French)

There are the scripts :

/////

the JS script attached to the caps

 var rb : Rigidbody;
 var cameraRotat : Transform ;
 var capsRotat : Transform;
 var Adapt : GameObject;
          
              
 function Start()
 
 {
     rb = GetComponent.<Rigidbody> ();
 }
 
 
 function FixedUpdate()
 
 { 
     capsRotat = GetComponent.<Transform> ();
     cameraRotat = GetComponentInParent.<Transform> ();
     
 
     
     rb.MovePosition (this.transform.position + transform.forward * Time.deltaTime * 3);
     
     transform.rotation.y = Adapt.transform.rotation.y;
 }

///////////////////

And the C# attached to the MainCamera

 public GameObject caps;
 public int i;
 public Vector3 offset;

 void Start () {

     offset = transform.position - caps.transform.position; 

 }

 void FixedUpdate () {

     transform.position = caps.transform.position + offset;

 }

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 centaurianmudpig · Oct 29, 2015 at 10:44 AM 0
Share

Hey, if I understand correctly you want the camera to turn and face your capsule?

If so, the code you posted only deals with position.

For rotation, you could use Transform.LookAt(). http://docs.unity3d.com/ScriptReference/Transform.LookAt.html

avatar image centaurianmudpig · Oct 29, 2015 at 11:45 AM 0
Share

O$$anonymous$$, then line 24 of the capsule script will be the focus of your investigation. You have set it to the Y rotation of the CardboardAdapter which will make your capsule face the same direction of the CardboardAdapter for the Y direction.

Does this CardboardAdapter have some 3rd party script, I can't see any reference to it in the Unity documentation?

FYI: Best use Add comment above my two posts for replying.

avatar image arkea · Oct 29, 2015 at 12:19 PM 0
Share

First, thanks to help me.

Yes there are more things than it on the objects :

$$anonymous$$ain Camera : There is the StereoController script (without him can't see into the two CadboradAdapter's children cameras)

CardboardAdapter (child of $$anonymous$$AinCamera) : there is the CardboardHeadscript(don't really know what he does...) The cardboardSdk.unitypackage is here if you want to see : https://github.com/googlesamples/cardboard-unity

But i display on the screen the axes and you have to know that it works but not for all angles :

Actually, it goes forward (the both rotation.y axes betwen -1 and 1 are displayed) and so -1 = +1 (180 = -180) and what i see is when i pass to the positive at negative or negative to positive it doesn't goes where i want anymore there is a little hysteresis that makes my capsule going in the wrong direction. (I know i'm not clear but it is already not clear for me...)

avatar image arkea · Oct 29, 2015 at 12:50 PM 0
Share

Now I'm sure about what's happening there is just an hysteresis problem, it is a double hysteresis because it occurs for two senses of rotation so i explain you precisely if you don't know what it is :

I explain you for the sense from positive to negetive :

so i'm at 0.8 and I go to 0.99 --> i continue and it keeps the 0,99 and decrease until about 0.8 where he understand "oh i'm not in postive direction!" so he puts a $$anonymous$$us and it works again.

For the other sense this is the contrary Am I clear enough ?

avatar image centaurianmudpig arkea · Oct 29, 2015 at 01:38 PM 0
Share

If it's a double hysteresis problem as you describe then it would be something inherited from your Adapt GameObject, given you use rotation.y unchanged. I have no experience of using Google Cardboard. I'll presume you have check out the Demo scene to gain an understanding of how the unity package works.

Google around, perhaps there is a social platform specific for Unity developers using this package. Otherwise, I hope someone else can help you :)

avatar image arkea · Oct 29, 2015 at 02:09 PM 0
Share

yes i looked but it's not worth because you can't move xD. you know i've wrote another code in C# which works great but i didn't succeed to just update the rotation.y, I update all the rotation so my capsule doesn't stay standing with the y axis toward the sky if I rotate my head on others axes that the Y^^ . So you'll tell me "It is not a problem" but IT IS, because in my app i don't just stay on the floor i've some stairs and if the player look toward the stairs the capsule lie down in function of the CadbordAdapter axes and so she doesn't climb the stairs. thanks to answered me ! :D

avatar image centaurianmudpig arkea · Oct 29, 2015 at 03:04 PM 0
Share

You misunderstand, I didn't say there was not a problem. To summarise my understanding the problem is on this line.

 transform.rotation.y = Adapt.transform.rotation.y;

You need to find out how Adapt.transform.rotation.y is used.

Best wishes :)

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by arkea · Oct 29, 2015 at 10:57 AM

no that is not what i want. The capsule is under the camera and she follow his local z axis and the camera follow the position of the capsule just for staying above the capsule

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 arkea · Oct 29, 2015 at 11:37 AM 0
Share

@centaurianmudpig

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

39 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

Related Questions

Quaternion Roation Mouse Script 0 Answers

Fix rotation skipping 0 Answers

Camera self rotation script problem 1 Answer

Rotate camera like VR on mobile 3 Answers

Switch between touchscreen and Google VR to control the Unity camera 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