Basic Combat Targeting Bug

@Jon_Whiteley mentioned this already in another thread a few months ago, but I didn’t see any responses.

It seems that when the RaycastHit gets multiple targets it doesn’t necessarily set the first one hit as the first one reviewed…

Are there any expectations to fix this bug in the course?

It look like this, I think because it’s in reverse order, we can use

for (int i = hits.Length - 1; i >= 0; i--)
{
     // some code
}

I don’t know if this is the right way to do it, but it looks like a solution :slight_smile:

This is actually covered in lecture 158, Raycast Sorting.

Privacy & Terms