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 code was not formatted so any generics will have been stripped out. Also there aren't 17 lines of code. Please include the full error message and tell us which of the lines that you paste get the error.
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;*
Your code was not formatted so any generics will have been stripped out. Also there aren't 17 lines of code. Please include the full error message and tell us which of the lines that you paste get the error.
– Statement