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 mazerunner_kn · Jan 17, 2019 at 10:15 AM · rotationpositionplayer movementtracking

How to make character movement track users head rotation

Below is the code I am using to track the player but the direction and rotation is not working and I don't know exactly why. Any help would be highly appreciated!

     using System.Collections;
     using System.Collections.Generic;
     using UnityEngine;
 
 public class PlayerTracking : MonoBehaviour {
 
 
     public GameObject ScatterplotCube;
     public GameObject User_HTCVive;
     public GameObject MiniMapcube;
     public GameObject Character;
 
     // Use this for initialization
     void Start () {
 
         //Vector3 repositionMinimap = MiniMapcube.transform.localPosition + new Vector3(0, 0.3f, 0.3f);
 
         //MiniMapcube.transform.localPosition = repositionMinimap;
 
     }
 
     // Update is called once per frame
     private void Update()
     {
         
     }
 
     void FixedUpdate() {
         // Position
         Vector3 VecPosition = ScatterplotCube.transform.InverseTransformPoint(User_HTCVive.transform.position);
         //Debug.Log(VecPosition);
         Vector3 tp = MiniMapcube.transform.localPosition + (VecPosition);
         transform.localPosition = tp;
 
 
 
         // Rotation
         Vector3 VecRotation = ScatterplotCube.transform.InverseTransformDirection(Vector3.zero);
         Vector3 tr = MiniMapcube.transform.rotation.eulerAngles + VecRotation;
         transform.rotation = Quaternion.Euler(VecRotation);
 
     }
 }

Comment
Add comment · Show 2
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 tormentoarmagedoom · Jan 17, 2019 at 10:23 AM 1
Share

Good day.

I dont understand what you mean by "traking". And what you mean with direction and rotation. The Camera? The character is not controlled by you? Why you need to "track" ?

It will be great if you help us to understand exactly what is happening and what you want to get.

$$anonymous$$ake some Paint draws for example, to easy transmit this info, And i see you have a variable called User_HTCVive. You should say in the title and as a tag, that is HTCVive project. This wil help HTC experts to see your post.

Bye!

avatar image mazerunner_kn tormentoarmagedoom · Jan 21, 2019 at 03:18 PM 0
Share

@tormentoarmagedoom Good day. Thank you for your reply!

I have a character inside a cube and the character moves when the user with the htc device in the head moves, but my problem is that when the user rotates it isn't tracking that rotation correctly.

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

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

Related Questions

[VR][VIVE] allow rotation only ? 4 Answers

How can I make an object transform to given position and rotation 2 Answers

HTC VIVE Tracker Object 1 Answer

Automatically flip a player game object upright on z axis? 1 Answer

Rotate y-axis of child object following a rigidbody sphere parent 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