- Home /
Invalid IL Code Error
I've reduced the code to the relevant parts. I thought maybe the enum was the problem (_type used to be an enum) and even made the parameters 0. I'm still getting the error.
Spoof, is a script attached to the GameObjects that the OverlapSphere is looking for, and it contains values for scanPower, thermalPower, laserPower. (But that's probably not relevant.)
I get no compiler errors. Just this at runtime:
InvalidProgramException: Invalid IL code in Missile:CheckSpoof (int,single): IL_001f: call 0x0a00004e
var target : GameObject;
_spoofed : boolean;
function Update () {
CheckSpoof(0, 0);
}
function CheckSpoof (_type:int, _spoofResistance:float) {
var _hitColliders = Physics.OverlapSphere(target.transform.position, 1000);
for (var h=0; h < _hitColliders.Length; h++) {
var _spoofScript:Spoof = _hitColliders[h].gameObject.GetComponent(Spoof);
var _spoofPower:float;
if (_type == 0) { _spoofPower = _spoofScript.scanPower; }
if (_type == 1) { _spoofPower = _spoofScript.thermalPower; }
if (_type == 2) { _spoofPower = _spoofScript.laserPower; }
if ( Random.Range(0.00f, 1.00f) <= _spoofPower * (1 - _spoofResistance) ) { // spoofed!
target = _hitColliders[h].gameObject;
_spoofed = true;
}
}
}
any Debug prints to see where it's actually stopping?
did you try initializing _spoofPower
?
are the variables you're accessing in the Spoof script all float
s?
which version of unity? which platform? iOS 64bit???
Your answer
Follow this Question
Related Questions
Import Componet ( Variable ) Error Unexpected Token 3 Answers
[SOLVED] Help with PlayerPrefs.SetInt 1 Answer
problem with mathf function 2 Answers
Problems with Input.acceleration in Unity 4.1 1 Answer
Function not valid macro 1 Answer