I currently have damage script calling a function from another script which is called shields. I've fooowed this guys video (http://www.youtube.com/watch?v=nEMneTf2Wcs) but when i start the game i get
"(20,36): BCE0020: An instance of type 'UnityEngine.GameObject' is required to access non static member 'GetComponent'."
Here is the script i am pulling the function from.
var maxShields = 100;
var curShields = 100;
function Start()
{
}
function AdjustCurShields(adjustShields:int)
{
curShields += adjustShields;
if (curShields>maxShields)
curShields=maxShields;
}
function Update()
{
if (curShields<=0)
Debug.Log("shields are down");
AdjustCurShields(0);
}
here is the script with the function i am calling from the other script.
function Start ()
{
}
function Update ()
{
if (Input.GetKeyUp(KeyCode.F))
{
Attack();
}
}
function Attack()
{
var AdjCurShields : Shields;
AdjCurShields = GameObject.GetComponent("Shields");
AdjCurShields.AdjustCurShields(-10);
}
Thanks in advance.
↧