The lookObjects array have two places in the inspector but they are empty. In the code the array lookObjects is not null and it's length is more then 0 but because the two places in the inspector are empty i'm getting exception.
The exception is on line 34 :
Vector3 lookAt = target.position - transform.position;
UnassignedReferenceException: The variable lookObj of IKTests has not been assigned.
In case i forgot in the inspector some items empty how should i handle it in the code ?
could be one empty item in the array and some other not empty. or maybe i forgot to assign them all.
CodePudding user response:
If you just need the lookObj that are not null then you can check target == null then continue, or another option is to remove all null objects from the list of lookObj: var lookObj = lookObj.RemoveAll(l=>l == null)