Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 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 Tamms · Feb 28, 2017 at 11:33 AM · movementvrcamera-movementcamera rotation

VR camera rotation

I'm trying to do a first-person camera controller for Gear VR and I'm having some problems with the rotation. How it should work: When mouse button is held down, the camera moves in the direction that it's facing. This works fine while testing in Unity, but not when testing with the Gear VR. Unity automagically tracks the head rotation and rotates the camera according to that. However, the headtracking doesn't seem to "really" change the rotation of the camera, since the direction of the movement doesn't change. Script for the movement:

             Vector3 movement = new Vector3();
             movement.z = Input.GetAxis("Vertical");
             transform.Translate(movement * Time.deltaTime * moveSpeed);

So when I hold the touchpad, it moves along the camera's (or the camera's parent object's) z-axis, no matter where I'm looking at. This has troubled me for a few days now and I just can't get it working.
(If you know the VR horror game Affected: The Manor, that's the kind of movement system that I'm trying to achieve. )

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Tamms · Mar 11, 2017 at 10:16 AM

I found a way around this, from this tutorial. I added a Character Controller component for the CameraContainer object, and added the following script for the CameraContainer:

 public class VRcameraMovement : MonoBehaviour {
 
     public Transform vrCamera;
     public float moveSpeed = 5.0f;  
     private CharacterController CharCont;
 
     // Use this for initialization
     void Start () {
 
         CharCont = GetComponent<CharacterController>();
         
     }
     
     // Update is called once per frame
     void Update () {
 
         if (Input.GetMouseButton(0))
         {
             Vector3 forward = vrCamera.TransformDirection(Vector3.forward);
 
             CharCont.SimpleMove(forward * moveSpeed * Time.deltaTime);
 
         }
     }
 }


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 Selzier · Aug 28, 2017 at 03:05 PM 0
Share

Glad the tutorial helped, thanks for sharing!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How can ı attach my camera to object for fps game ? 0 Answers

How to stop 3rd person camera going throught walls ? 1 Answer

Smooth Follow cam; how to keep camera close, but still retain sideways lag/lerp 1 Answer

Footstep sounds system with a Vr touchpad movement system 1 Answer

Panning and Rotating a Camera 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