This is a similar question to the last one. Since i couldnt figure out JavaScript for Flash i decided to try it in C#… Im not good at c#. Here is my script
using UnityEngine;
using System.Collections;
public class PlayerWeapons : MonoBehaviour {
void Start () {
SelectWeapon(0);
}
void Update () {
if(Input.GetKeyDown("1")){
SelectWeapon(0);
}
if(Input.GetKeyDown("2")){
SelectWeapon(1);
}
}
void SelectWeapon(int index){
For(int i=0; i<Transform.childCount; i++)
{
if(i == index)
Transform.GetChild(i).gameObject.SetActiveRecursively(true);
if(i != index)
Transform.GetChild(i).gameObject.SetActiveRecursively(false);
}
}
}
And here are the errors
Unexpected symbol
i', expecting
.’Only assignment, call, increment,
decrement, and new object expressions
can be used as a statementUnexpected symbol
)', expecting
;’Parsing error
Any help is appreciated