Mufark
1
I bet you’ve seen it all before a million times. But I have scrolled through countless examples and tried with no change. I am currently beginner at both C# and unity.
I am trying to get my model to equip/hold a weapon when i start the game. I have created a child to the hand and turned off mesh and box collider.
I have then created the following C# script;
public GameObject HookRightHand;
void start(){
GameObject sword = GameObject.Find ("sword-1");
EquipMainHandWith (sword);
}
public void EquipMainHandWith(GameObject weapon){
weapon.transform.parent = HookRightHand.transform;
weapon.transform.localPosition = Vector3.zero;
}
}
I have then attached the child to the script which is name HookRightHand.
The weapon prefab is named sword-1, the model used is named sword_wooden. I have tried using both names with no luck.
Everytime i run the game the sword just sits in the air and doesn’t follow as intended. What am i doing wrong? or what am i missing?