Alright this script has been put on an empty game object which contains my player. THe player has two scripts (different weapons/guns.etc) and with the key input of different keys I want it to enable and disable script. Probably another nib question.
using UnityEngine;
using System.Collections;
public class WeaponChoose : MonoBehaviour {
private bool pistolequiped = true;
private bool shotgunequiped = false;
// Update is called once per frame
void Update () {
if ( Input.GetKeyDown ("1"))
{
if (pistolequiped == false)
{
GetComponent("PistolScript").enabled = true;
GetComponent("ShotgunScript").enabled = false;
}
if (pistolequiped == true)
{
// sounds etc,
}
}
if ( Input.GetKeyDown ("2"))
{
if (shotgunequiped == false)
{
GetComponent("PistolScript").enabled = false;
GetComponent("ShotgunScript").enabled = true;
}
if (shotgunequiped == true)
{
// sounds etc
}
}
}
}
I get the error: Assets/WeaponChoose.cs(26,34): error CS1061: Type `UnityEngine.Component' does not contain a definition for`enabled' and no extension method `enabled' of type`UnityEngine.Component' could be found (are you missing a using directive or an assembly reference?)
Have I mixed up my Java with C# during the scripting or am I just doing something wrong. Cheers, (Im off to sleep now will check on answer in the morning)