Hi All,
ı have no had so much experience about Unity3d. These theys ı am focusing on my own project.
In a part of my project, there are sıme object loaded my world at runtime. However, when ı Instantiate a object, I cannot control object rotatin. I can take under control of position and scale but not rotation. Here is part of my code:
public void olustur(string hangisi, Vector3 pos, Vector3 scale)
{
Debug.Log(hangisi);
gom = Instantiate(Resources.Load(hangisi)) as GameObject;
gom.transform.position = pos;
gom.transform.localScale = scale;
gom.name = "dedee";
numberFirst = gom.transform.childCount;//child sayısı bulunuyor
Debug.Log("numer first: " + numberFirst);
deneme += 1;
if (deneme==3)
{
deneme = 1;
}
for (int i = 0; i < numberFirst; i++) //herbir child tek tek bulunuyor ve onlara mesh collider ekleniyor
{
gom.transform.GetChild(i).name = "firsler_"+deneme+"_"+ + i;
nameFirst = gom.transform.GetChild(i).name;//child ismi alınıyor
firstChildren = GameObject.Find(nameFirst);//isme göre child game object olarak bulunuyor
Debug.Log("firstün nameleri" + firstChildren.name);
numberSecond = firstChildren.transform.childCount;//child için 2. child var ise kontrol ediliyor
Debug.Log("number second= " + numberSecond);
for (int j = 0; j < numberSecond; j++)// bunun da childleri var ise aynı işlemler yapılıyor
{
nameSecond = firstChildren.transform.GetChild(j).name;
secondChildren = GameObject.Find(nameSecond);
mc = secondChildren.AddComponent("MeshCollider") as MeshCollider;// 2. child lara mesh colider ekleniyor
}
mc = firstChildren.AddComponent("MeshCollider") as MeshCollider;// ilk child lara mesh collider ekleniyor
Debug.Log("mesh eklemesi lazım");
}
}
by useing this code the object’s face rotation is same with first user controller but i want to ınstantiate them as face to face ewith first user.
when ı use
gom.transform.rotation = new Quaternion(270, 180, 0, 0);
the object rotation is much difference then ı expected.
Please help me about the rotation. ı want to ınstantiate objects as ı see in inspector panel.