Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Same objects with different scales - rotations are wrong

Discussion in 'Editor & General Support' started by CarlY, Aug 19, 2014.

  1. CarlY

    CarlY

    Joined:
    Nov 5, 2013
    Posts:
    29
    Hello,

    I've two objects in my scene. First one is a rock mesh, the other is the same rock with an animation. When the player triggers oncollisionenter, I switch the rock mesh with the animated one. The rocks have the same size in the scene but their scales are different since Unity does something funky when it imports fbx animation. So when I do something like this:

    Instantiate(Rock2, Rock1.transform.position, Rock1.transform.rotation) ;

    It spawns with a different rotation than Rock1. Debug shows that both objects have the following rotation:
    (0.6, -0.4, -0.4, -0.6)

    What should I do, so that the animated rock spawns in the correct place?
     
  2. TRuoss

    TRuoss

    Joined:
    Dec 5, 2012
    Posts:
    85
    keep in mind that the debug.log rounds the floats. try something like quaternion.x.ToString("f4") and you will get 0.0000 values.

    This will not solve the problem but helps when you debug.

    Edit: most of the time I instantiate with Quaternion.identity and than apply local or global rotation afterwards.
     
  3. CarlY

    CarlY

    Joined:
    Nov 5, 2013
    Posts:
    29
    Thanks for the tip TRuoss. I found the culprit. It's the fbx animation itself not the rotation code. Gonna open another thread about it.