- Home /
Rotating an object
Following some example code i am using the code below to rotate an object to be aligned with the current phone tilt/rotation.
The problem is that when i tilt/rotate the phone left then the object i'm rotating rotates right. Meaning that the object does not rotate the same way the phone rotates. I have tried a lot of different solutions to fix it, but nothing has worked. Does anybody have any idea how i can fix it to make it match the phones rotation/tilt?
var temp = MovAverage(Input.acceleration.normalized);
temp.z = 0;
foreach (var t in GameMaster.CurrentTiles)
{
if (t == null) return;
t.transform.up = temp.normalized;
}
Answer by haueve · Sep 09, 2014 at 09:56 AM
It did not work when i negated the whole vector with temp *= -1; It would seem i had to negate only the y axis.
temp.y *= -1;
Your answer
![](https://koobas.hobune.stream/wayback/20220613162614im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
how can i stop rotating gameobject but slowly 1 Answer
Rotation not working as expected 0 Answers
Why is this rotation acting odd? 0 Answers
Set a relative (custom) speed to a rotation 1 Answer
Drag object in a circle path 1 Answer