EDIT: Have discovered that if I remove the animation from my sword, it appears. What good is that though, having a weapon I can’t use, unless this is jousting?
Ok, so my original question asked about getting a weapon switching script working, which I’ve now done, praise God! =) There’s a strange issue now though, and thought I’d throw it out to the community. If I follow exactly as the tutorial here shows, add the script (below), parent script to main camera, child an empty object to the main camera (a weapon manager, so to speak) and child a cube (weapon) and sphere (another weapon) to that manager, everything goes swimmingly, I can switch between the cube and sphere. Yay! Accept, nobody wants to carry a cube or sphere around as a weapon. No problem, right? That’s just proof of concept. I’ll just add my sword on there, which I’ve been using with no issues for the longest… wait, dude, where’s my sword? It’s like, not there! I mean, I did check to make sure there were slots for three weapons, and nothing. Cube and sphere are there just fine, but my sword (a 3d model) doesn’t appear. Once again, any help or advice is humbly accepted and appreciated. God bless.
function Start () {
// Select the first weapon
SelectWeapon(0);
}
function Update () {
// Did the user press fire?
if (Input.GetButton ("Fire1"))
BroadcastMessage("Fire");
if (Input.GetKeyDown("1")) {
SelectWeapon(0);
}
else if (Input.GetKeyDown("2")) {
SelectWeapon(1);
}
else if (Input.GetKeyDown("3")) {
SelectWeapon(2);
}
}
function SelectWeapon (index : int) {
for (var i=0;i<transform.childCount;i++) {
// Activate the selected weapon
if (i == index)
transform.GetChild(i).gameObject.SetActiveRecursively(true);
// Deactivate all other weapons
else
transform.GetChild(i).gameObject.SetActiveRecursively(false);
}
}