I’m using this in my code to rotate a collectable, but not sure how to change its rotation
void Update()
{
transform.localRotation = Quaternion.Euler(90f, Time.time * 100f, 0);
}
I’m using this in my code to rotate a collectable, but not sure how to change its rotation
void Update()
{
transform.localRotation = Quaternion.Euler(90f, Time.time * 100f, 0);
}
In this case, you should try to make sure you leave the parents’ rotation at 0,0,0.
You risk running into gimbal lock depending on the parent’ rotation, then you might not be able to rotate the item the way you want at all. When running your code I ran into gimbal lock at certain rotations of the parent.
If you can’t do that, you can orient and rotate the item in two steps:
transform.localRotation = Quaternion.Euler (90f, 0, 0);
transform.Rotate (Vector3.up, Time.time * 100f, Space.World); //Rotate on the world y-axis
Hello @nociception,
The Quaternion.Euler takes 3 parameters: x, y and z, all you need to do is change each value at a time to know which one is the right one
But I can also see that you are affecting the variable localRotation which is the rotation of your object based on it’s parent’s rotation, make sure that you need the parent rotation otherwise you can use transform.rotation
I was able to fix it, but thank you for the tips :)
– nociception