Instantiate Oriantation problem

Hi Guys,

Having what I hope is a simple problem with instantiate. Basically im trying to create a model viewer type thing in Unity. im using Unity 3.4.0f5 Indie and Studiomax.

I have a scene all nicely lit and imported, this is fine, then im using an empty game object to spawn items into the scene and am using an orbit camera so the user can view the items. Ultimately I wnat to create a menu system where the user selects an object from the database and the selected object spawns onto this emptygameobject in Unity.

The problem im having is that the object when spawned in Unity is Orientated in random directions and im not sure what is controlling it.

Heres my process:-

  • I rotate and centre the object on Y axis ready for export from studiomax (ive chosen y axis as my ‘facing’ direction when exporting all objects to make sure each object is exported consistantly.)
  • Export as .fbx and import the .fbx into Unity
  • Create a prefab and assign the imported model to the prefab (I have to do this as all these items will be used over and over in the game world)
  • I have a Emptygameobject gizmo placed in my scene with a very basic instantiate script assigned.
  • I add my Object prefab to the Emptygameobject and hit play.

My very basic instantiate script is:-

var weapon_pf : GameObject;
function Start () {
var instance : GameObject = Instantiate(weapon_pf, transform.position, transform.rotation);
}

Having done this with 4 different objects, all exported from the same scene in max (to double check orientations and settings are identical), not changed anything in Unity apart from creating the indervidural prefabs for each item(with default position/orientation settings,=) and then trying each prefab 1 by 1 on the exact same emptyobject in Unity they all come out facing completely different directions.

Why? what is controlling this and how do I stop it?

Many Thanks,

John

Not sure if Max has this ‘feature’ but sounded similar to the problem I had with blender export!

In blender when you rotate or scale an object you have just set a transform so until you apply the transform what you export will be the objects original transform.

Cheers for the suggestion Arowx

I figured it out in the end and it wasn’t anything to do with the import. More newbiness when it comes to Unity.

In the end I set the spawn up as a prefab adjusted the settings and dragged it into the scene, seems to work perfectly now.

Regards,

John