Search Unity

Object orientation.

Discussion in 'Scripting' started by D1382, Jun 2, 2012.

  1. D1382

    D1382

    Joined:
    Jun 2, 2012
    Posts:
    6
    So I'm very new to unity. Just getting my feet wet and enjoying every minute of it.

    In my current project I'm making a simple battleship that has 2 turrets. I have a very simply script that uses transform.LookAt(target) to aim the cannons at an object.

    All works 99%. The issue I'm having is the "front" of my turret (or boat even) is 90 degrees off. So the side of the turret faces the target as opposed to the barrels.

    Any ideas to help me out?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,137
    Rotate the model in your 3D app so it works correctly in Unity; there's no standard orientation between different programs.

    --Eric
     
  3. D1382

    D1382

    Joined:
    Jun 2, 2012
    Posts:
    6
    That was the first thing i tried. It seemed like it would be easy and not an issue.

    For some strange reason if I change the orientation of the turrets/boat in maya. it has no effect in unity.
     
  4. superpig

    superpig

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,184
    You need to change the orientation of the mesh's 'pivot' rather than just rotating the whole mesh - i.e. the local coordinate system for the mesh needs to change.
     
  5. D1382

    D1382

    Joined:
    Jun 2, 2012
    Posts:
    6
    Any more help on this? I feel like I'm doing what I should be. but I'm not getting the results I want.
     
  6. D1382

    D1382

    Joined:
    Jun 2, 2012
    Posts:
    6
  7. D1382

    D1382

    Joined:
    Jun 2, 2012
    Posts:
    6
    Solved.

    What was frustrating me the most is whenever I rotated the object in maya the rotation was exported along with it. So in the Inspector in Unity would also reflect that rotation (ie: -90* on the y axes).

    So the solution was simply freeze the transformations.

    Modify > Freeze Transformations
     
  8. neopaul78

    neopaul78

    Joined:
    Jan 15, 2016
    Posts:
    4
    S O L V E - use own Unity pivot system "Hinge Joint", it is not based on exported pivots of Max or etc