I am having a tough time with this and hoping someone can give me a hand. When I equip a weapon, I am Instantiating the weapon from a prefab, and parenting it to an empty gameobject. The problem is that it is never rotated correctly. What I am doing is this, I set it up weapon prefab (say a sword). I pull a character into the scene, then move the weapon where I want it to position it on my character, then child it to the weapon mount. Save the weapon prefab, then run my game, equip the item.
How can I ensure that the weapons are always facing the right direction, and are rotated correctly so when I instantiate them, it works correctly. What am I missing here??
if (Core._playerCharacter.GetEquipedItem(equipRegion) == null)
{
InventorySystem.RemoveItem(item);
Core._playerCharacter.EquipItem(item);
equipIcons[pos] = item.InventoryIcon;
CharacterAsset chrAsset=(CharacterAsset)Core._playerCharacter.CharacterModel.GetComponent("CharacterAsset");
foreach(GameObject go in chrAsset.equipRegion){
if(go.name == equipRegion.ToString()){
foreach (GameObject obj in chrAsset.equipment)
{
if (item.Name == obj.name)
{
//temp = the mesh we are loading
temp = (GameObject)Instantiate(obj);
temp.transform.position = go.transform.position;//new Vector3(0, 0, 0);
//temp.transform.rotation = go.transform.rotation;
//temp.transform.localPosition = new Vector3(0, 0, 0);
temp.transform.localRotation = new Quaternion(0,0,0,0);//.Euler(0, 0, 0);
temp.transform.parent = go.transform;
_gameObject.Add(pos, temp);
item.Equipped = true;
}
}
}
}
}