I am creating a measure app for iOS using Unity. I was able to measure distance between 2 points and show it in a GameObject
. This is what I have achieved so far: [.[Measure something on the floor. User looking at top][1]][1]
[![Measure horizontally on vertical plane][2]][2]
My update method is like this.
if(textObj.activeInHierarchy == true)
{
direction = pointTwo - pointOne;
textObj.transform.right = direction;
}
textObj
is the white color measure indicator. pointOne
and pointTwo
are the starting point and ending point of the line.
I want to show this measure indicator always readable to the user regardless of his position. But in my case(second picture), the indicator should be tilled towards the user around its X axis and its Z axis always should be perpendicular to the drawn line.Its Y axis should always face towards the inverse direction of camera.transform.forward. I tried adding
textObj.transform.up = -arCamera.transform.forward;
before set the textObj.transform.right = direction;
but that doesn't change any. But you can see in Apple Measure app the distance indicator is always readable to the user regardless of his position. How can I achieve this? Please help me.
Thanks: [1]: https://i.stack.imgur.com/OQnmA.png [2]: https://i.stack.imgur.com/Hxwln.png
You can try this method: https://docs.unity3d.com/ScriptReference/Transform.LookAt.html
In you case you want the text object to look at the camera. The second parameter is a Vector specifying the upward direction, using the default value of Vector3.up
it should work for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.