Browse Source

Fix hierarchy to make translation and rotation of mesh working

Johannes Kreutz 2 years ago
parent
commit
c3e0ed04f7
1 changed files with 5 additions and 1 deletions
  1. 5 1
      track-client/TrackClient/Assets/TrackpointApp/SteamVRTrack.cs

+ 5 - 1
track-client/TrackClient/Assets/TrackpointApp/SteamVRTrack.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using Newtonsoft.Json;
 using UnityEngine;
 using Valve.VR;
 
@@ -8,13 +9,16 @@ public class SteamVRTrack : TrackpointMesh
 {
     public string filePath;
 
+    private GameObject meshObject;
     private TrackpointMesh trackpointMesh;
     private SteamVR_TrackedObject tracking;
     
     // Start is called before the first frame update
     void Start()
     {
-        trackpointMesh = gameObject.AddComponent<TrackpointMesh>();
+        meshObject = new GameObject();
+        trackpointMesh = meshObject.AddComponent<TrackpointMesh>();
+        trackpointMesh.transform.parent = this.transform;
         trackpointMesh.setup(filePath, TrackingSystem.SteamVRTrack);
         setupTrackpointTranslationAndRotation();
         tracking = gameObject.AddComponent<SteamVR_TrackedObject>();