Alright, I’ve created a way to get a component from either the current object or from its children, if I try to do this in a script it works fine but when I try it in this static function it won’t work.
here’s the function:
public static function GetIPU(ob : GameObject):ItemPickUp{
var fppu : ItemPickUp = ob.GetComponent("ItemPickUp");
if(!fppu){fppu = ob.GetComponentInChildren(typeof(ItemPickUp));}
return fppu;
}
I’ve also tried this:
public static function GetIPU(ob : GameObject):ItemPickUp{
var fppu : ItemPickUp = ob.GetComponent("ItemPickUp");
if(!fppu){return ob.GetComponentInChildren(typeof(ItemPickUp));}
if(fppu){return fppu;}
}
Still no luck, please help me find out what is wrong with this.
I heard that GetComponentInChildren gets in the current object or its children but this is false from what I’ve tried.