- Home /
Help with small scripts. Probably typo.
There are console errors :
Temp/Assembly-UnityScript.dll
Assets/IgracGlavno.js(13,13): BCE0043: Unexpected token: allTargets.
Assets/IgracGlavno.js(13,46): BCE0043: Unexpected token: ).
Assets/IgracGlavno.js(15,32): BCE0044: expecting }, found '='.
Assets/IgracGlavno.js(15,33): UCE0001: ';' expected. Insert a semicolon at the end.
Assets/IgracGlavno.js(20,1): BCE0044: expecting EOF, found '}'.
This is script:
var range:float;
var damage:float;
function Attack(){
//enable either one of this
layerMask=3<<8; //target both land and air
//~ layerMask=1<<8; //target land unit only
//~ layerMask=1<<9; //target air unit only
var allTargets:Collider[]=Physics.OverlapSphere(transform.position, range, layerMask);
for(allTargets:Collider in allTargets)
{
targetCom:Creep=target.gameObject.GetComponent.<Creep>();
targetCom.ApplyDamage(damage);
}
}
What is wrong?
Answer by syclamoth · Jan 03, 2012 at 01:46 PM
You shouldn't be defining 'allTargets' twice (which is what you are doing in that for statement). Instead, I think you want this-
for(target : Collider in allTargets)
given that you later call 'target.gameObject'- and I'm not seeing where else that 'target' thing would come from.
Also, I'm fairly certain you need a 'var' in front of targetCon.