Unable to read rotation data from Gyro
Hi There,
I am trying to extract rotation data from a Gyro component in their raw form (as an angle preferably) however I cannot seem to find where they are being stored. I can see that the sprite that the gyro is attached to moves along with the gyro, but I cannot see changes in the rotation vector when retrieving the attached transform of both the gyro and the sprite moving along with the gyro (which I assume would return the same transform). I am printing out parts of the rotation quat every few seconds however they don't appear to change, even though the spirte object is moving.
I think I am not printing out the rotation data correctly. I would like to essentially have an output of the angles of the gyro.
Is there anyone who can walk me through this?
Are you printing out the quaternion values every frame update? Maybe you are not getting the values updated every frame. Binding a function to the UpdateEvent Event can give you real-time information about the gyroscope.
function onUpdate(event){
print(""+quat.x);
}
var frameEvent = script.createEvent("UpdateEvent");
frameEvent.bind(onUpdate);
Ah yes Thank you Andrew you have just made me realise my mistake! I was updating the print out every frame but the problem was I think getTransform() only returns a Copy of the transform as opposed to pointing to where the object is actually stored - this was not being updated and I now seem to be getting much better looking data, thanks for that!
No problem! Glad to of helped :) Share you lens when its done, would love to see it :)