for (int i=0; i < nrWeapons; i++) {
if (i == index) {
//weapons*.gameObject.SetActive(true);*
weapons*.gameObject.GetComponent ().enabled = true;* } else { //weapons*.gameObject.SetActive(false);* weapons*.gameObject.GetComponent ().enabled = false;* } } } not sure why I am getting this error plz help at 17,9
Your script must define those variables. I think it’s safe to eliminate nrWeapons and use weapons.Length instead. I don’t know what type the weapons array is meant to be.
using UnityEngine;
using System.Collections;
public class Weaponchanging : MonoBehaviour
{
public Component[] weapons; // WARNING! I don't know what type you expect!
void SwitchWeapon(int index)
{
for (int i=0; i < weapons.Length; i++) // Using weapons.Length instead of other var.
{
if (i == index)
weapons*.gameObject.GetComponent<RTCTankGunController> ().enabled = true;*