I have an empty gameobject ‘NPCs’, in here I have one gameobject ‘carl’ , this is a NPC (position is not fixed throughout entire game).
I have a prefab called ‘ArrowCylinder’ which is a small cylinder with an arrow texture on it.
In my code I want to show the ArrowCylinder prefab on top of carl’s head. Everything is working perfectly except that this gameobject has his rotation on y always set to 135. It needs to be set to 0 on the y.
My code looks like this:
GameObject npcObject = GameObject.Find("carl");
Vector3 npcPosition = npcObject.transform.position;
Vector3 pos = new Vector3(npcPosition.x, npcPosition.y + 3, npcPosition.z);
GameObject arrow = Instantiate(prefabCyl, pos, Quaternion.Euler(0,0,0)) as GameObject;
//arrow.transform.Rotate(0,0,0);
arrow.transform.parent = npcObject.transform;