Question by
RealSoftGames · Sep 18, 2017 at 05:22 AM ·
quaternionsminimaprotationscompass
Rotation Issues with compass markers not positioned correctly
Hello, i am having some issues with a compass im working on, i can not seem to get the icon on the edge of the compass to stay aligned to the edge of the compass when rotated in VR it works fine if it were on a flat surface however due to it being in 3D and its able to be rotated its causing some issues
This is how it should look in any orientation, however it only works if its held reasonably flat when the compass is tilted it ends up like this
this is my current code
Vector3 dir = radarObjects[i].owner.position - transform.position;
dir.y = 0.005f;
dir.Normalize();
radarObjects[i].icon.transform.position = transform.position + dir * radius;
Debug.DrawLine(transform.position, transform.position + dir * radius, Color.green);
//These are some of the alternatives i have attempted
Quaternion rot = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(dir), 1);
Vector3 forwardVector = Quaternion.Euler(rot * transform.forward) * transform.forward;
Debug.DrawLine(transform.position, transform.position + ((Quaternion.LookRotation(dir) * transform.right) * radius), Color.green);
Comment