Hello,
I have a vehicle with a headlight mounted on top of it. If the vehicle takes a left turn, so will the headlight. However, a player should still be able to move the headlight using the gyroscope. My phone app sends the attitude member of the gyroscope class provided by unity (which is a quaternion for the absolute orientation) to my desktop computer. My guess was to first convert the handedness to work with Unity and then assign the attitude to the headlight’s rotation. However simply assigning it like this will override the effect of the headlight moving with the vehicle, which I achieved by simply making the headlight a child of the vehicle itself.
Another issue I have to take care of is to add a calibration process which makes sure after calibration, your phone and the headlight are aligned. The way I want the player to hold his/her phone is in landscape mode with the camera pointing forward. Where the camera is looking is therefore the viewing direction. I have tried to add a calibration step by first letting the user hold his phone in landscape with the camera facing towards the screen and then press a button (to take a sample value of the current rotation) and then holding the phone in a way that the headlight in game is pointing straight (to take the final sample value). Then I calculate the offset between both quaternions using the inverse and finally multiplying the current rotation by the offset in the correct order. However the result is not correct. Up and down in game are more like rotating the phone from top left to bottom right. Left and right are similarly wrong.
I have been stuck with these issues for a long time now. I hope someone will be able to help me with it.
Best regards!