- Home /
Control object yaw by two axis
I'm developing AR application and I need implement custom real-world map (like Google map) which would be controlled just like there. To implement this I decide to set user marker facing direction based on AR camera rotation. It works good when I'm hold my phone vertical and rotate camera by Y-axis. But it works terrible when I turn my phone horizontally. At this moment user marker direction is different from camera Y-axis, and correspond to Z-axis. The question is: how to implement user marker facing based on Y and Z rotation values of AR camera?
P.S for better understanding I recommend to look on behaviour in "Google Maps" application. Try to hold device vertical and rotate it by Y-axis and than turn your phone horizontal and rotate it by Z-axis. Behaviour of user marker would be the same.
Answer by BBIT-SOLUTIONS · Mar 27, 2020 at 03:07 AM
Sounds like you are trying to use global axis and/or global rotation. Did you try to use localRotation instead already?
Yes, I'm using localRotation now. The problem is I can't always control marker facing only by Y-axis of camera. When I rotate phone horizontally marker facing correspond to Z-axis of camera. And the question is how to combine these behaviours (rotating on Y-axis when phone in verical position and on Z-axis when phone in horizontal position)
$$anonymous$$aybe use a simple if-condition. Something like that:
if(Screen.width>Screen.height){
//rotate around Z-axis
}
else{
//rotate around Y-axis
}
Your answer
Follow this Question
Related Questions
How would I interpret angular displacement from target rotation to max out at 180°? 3 Answers
How to snap a model to the direction being moved in, without also rotating the character controller 3 Answers
Get angle around a specified axis. 1 Answer
Getting the face direction 2 Answers
Rotate object so a specific axis faces another object, while also relative to the parent direction 1 Answer