I am writing Objects to a MySQL database which is working but the rotation of the object is is wrong for example the Rotation on Y of the object is 45.00000 but the value being set in the Debug.Log is “Transform Y: -0.9704478”
On this transform there is no value that anywhere that this value equals I have no idea where it is coming from.
void prepData()
{
bodies = GameObject.FindGameObjectsWithTag("Savable");
_GameItems = new List<data>();
data itm;
foreach (GameObject body in bodies)
{
itm = new data();
itm.ID = body.name + "_" + body.GetInstanceID();
itm.Name = body.name;
itm.levelname = Application.loadedLevelName;
itm.objectType = body.name.Replace("(Clone)", "");
itm.posx = body.transform.position.x;
itm.posy = body.transform.position.y;
itm.posz = body.transform.position.z;
itm.tranx = body.transform.rotation.x;
itm.trany = body.transform.rotation.y;
itm.tranz = body.transform.rotation.z;
_GameItems.Add(itm);
Debug.Log("Transform Y: " + itm.trany.ToString());
}
Debug.Log("Items in collection: " + _GameItems.Count);
}
Thanks heaps whydoidoit. Exactly what I needed. Just one question what is body.transform.rotation.y looking at? and where is it getting its value?
– RabbitIt's basically a complex number system that uses cosines and sines of angles around an axis to describe a rotation - as such it doesn't suffer from "gimbal" lock which is caused by a rotation being able to be described by multiple different euler angle combinations - but as euler angles are applied as 3 movements, it is possible that you cannot get a rotation to move smoothly between two values. I wrote this article on Quaternions: http://unitygems.com/quaternions
– whydoidoitThanks going to read now
– Rabbit