- Home /
Rotation angles not corresponding (inspector, debugging)
i everyone,
At this moment i collect translations and rotations from a seperate file through an Streamreader. From this file I access for example the transform of {x= 0,1 , y=0,4 ,z =0.55, w =10, p=-80, r=-0,725}. This looks all fine and i would like to move an object to that point. When doing such thing I let the object move to the specified transform and create a breakpoint (or printing with Debug.log) to check the transform values in visual studio. These values correspond to the values specified above. However when I'm watching the values in the unity inspector, they give me rotations that are close to the specified ones, but not precisely the same (e.g. {x=0.1,y=0.4,z=0.55, w=9.944, p=-79.938, r=0.713}). I understand that there are floating points and some of the error could come from floating points when using decimal values, but i dont understand why this error would be this big (10 degrees vs 9.944 degrees is a big difference in my program) and why does the debugger give the correct values and the inspector a different one.
if someone can enlighten me i would many thanks.
greetings Hoogemast
As the inspector shows local rotation, is it possible that the objects have a parent object that is not exactly rotated to 0,0,0 ?
Nope, the gameobject i use is the parent and the script is also attached to the parent.
When doing such thing I let the object move to the specified transform
Is that an animated move? Depending on how you do it, you sometimes don't reach 100% of the target values.
$$anonymous$$g. check this code:
public IEnumerator FlyTo( Transform start, Transform end, float duration )
{
Vector3 start_position = start.position;
Vector3 end_position = end.position;
float elapsed = 0;
while (elapsed < duration)
{
float v = elapsed / duration;
start.position = Vector3.Lerp( start_position, end_position, v * v * (3.0f - 2.0f * v) );
elapsed += Time.deltaTime;
yield return null;
}
start.position = end.position;
}
Without the start.position = end.position you wouldn't always reach the target value exactly.
Your answer
Follow this Question
Related Questions
How to get inspector rotation values ? 2 Answers
Issue finding an angle with trigonometry 1 Answer