- Home /
MagicLeap controller
I'm running under the update method a PickUp script. I've tried using a parent gameObject that it's positionend where I want it, but when I move the prefab inside the empy gameobject the origin of my gameobject matches the one with my prefab. So, I'm trying to build an offset for the position and rotation. The position works fine, but I can't figure out a way to correct the rotation. Thank you!
transform.position = controller.transform.position +Poscorrection; transform.rotation = controller.transform.rotation + Quaternion.(0.0f,90.0f,-30.0f) ;
Answer by gwuwer-mms · May 14, 2021 at 02:39 PM
You should not use Quaternions like this. These are not x,y,z axes like in the Unity Editor. This is not a specific magic leap question. What you can do:
Try to change your rotation with e.g:
transform.position = controller.transform.rotation + Quaternion.Euler(0, 90, -30)
Or something similar there are many options to transform quaternion to a easier to understand Rotation Vector
Learn more about how Quaternions/Rotation in Unity works (highly recommended)
But all of that would be overkill for your use case. In our project, we also need to attach something to the MagicLeap controller with an offset in rotation and position. We simply change the parent object to the controller upon picup.
go.transform.parent = controller.transform;
so you do not have to mess around with rotation at all.