r/Unity3D•
Bauns

Invalid code? (c# / unity networking)

Hello,

I'm currently getting an InvalidProgramException error, or Invalid IL, by using this segment:

if (CmdFindHealth(hitID, shotDamage) <= 0.0f){
       
    UpdatePlayerKillFeed(hitID, 1, false);
                   
}

The actual line that is causing problems is the "CmdFindHealth" call, which is referring to:

[Command]
float CmdFindHealth(string enemy, float damage)
{
    //GameObject go = GameObject.Find(enemy);
    //Health h = go.GetComponent<Health>();
    //return h.health;
    return 10.0f;
    
}

Even when I use ten as a value, I'm still getting the error. I have no idea why I am getting this error, but hopefully someone does. Is this just something that I can't do?

Edit: Fixed, apparently return types don't work with commands.

Posted Aug 12, 2015, 4:40 PM UTC · edited

17
Loading comments…