Hi guys.The thing is I found a script on the forums which is perfect for my game.The problem however is that due to how it is written the game object that the script is attached to rotates by 90 degrees automatically before any input is detected. What I want to do is have the game object rotate only when input is detected.
I’m not much of a coder but I had the script tweaked so it worked how I wanted it before all my data was lost.Since then I’ve been at this script for about a month and I haven’t gotten anywhere with it at all.
Here is the link to the forum page where i found the script.It’s in c# and done by Jesse Anders. http://forum.unity3d.com/threads/86174-Rotating-object-on-2-axis
And here is part of the script that causes this.In the script the line of code transform.rotation = orientations[orientationIndex];
is what sets the rotation of the object at the beginning. If i comment it out or change it slightly then the game object starts doing crazy rotations.This is as far as I managed to get in this entire time sadly.
void Start()
{
Quaternion[] rotations = new Quaternion[] {
Quaternion.AngleAxis(-90, Vector3.up),
Quaternion.AngleAxis(90, Vector3.up),
Quaternion.AngleAxis(-90, Vector3.right),
Quaternion.AngleAxis(90, Vector3.right)
};
for (int i = 0; i < 24; ++i)
{
for (int j = 0; j < 4; ++j)
{
var currentOrientation = rotations[j] * orientations[i];
float maxDot = 0f;
int neighborIndex = 0;
for (int k = 0; k < 24; ++k)
{
float dot = Mathf.Abs(Quaternion.Dot(currentOrientation, orientations[k]));
if (dot > maxDot)
{
maxDot = dot;
neighborIndex = k;
}
}
neighborIndices[i, j] = neighborIndex;
}
}
transform.rotation = orientations[orientationIndex];
}
Any help with the script would be appreciated.That includes hints and tips :razz:
Thanks in advance.
Peace!