Browse Source

Fix hierarchy to make translation and rotation of mesh working

Johannes Kreutz 2 năm trước cách đây
mục cha
commit
c3e0ed04f7

+ 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>();