Potential Future issue - Multiple CombatTargets with RaycastAll()

If your ray happens to intersect multiple CombatTargets a single click will cause your fighter to attack all of the intersected targets. I tested it by putting two targets next to eachother and saw it triggers twice (as expected) when RaycastAll() is used and when the mouse click is on a screen point where there are two targets.

I haven’t tried fixing it yet, since I imagine it will be addressed later on when we get into game play. I could imagine the specifics of the attack method should dictate what actually happens.

Flagging it here in case at some point in the future someone has a bug where their character is hitting multiple enemies with what should otherwise be a single enemy attack.

While it certainly looks that way, Fighter will always attack the last target it was set to attack, meaning your click will tell Fighter Attack(enemy1); Fighter.Attack(enemy2) and enemy2 will overwrite the value of target in Fighter.

Some of this is, however, dealt with in the Final Polish section where we’ll actually sort all the raycast hits by distance and choose the closest to act on.

other way to handle this is using “return” after the Attack() call. this attacks only the first enemy reached by the RaycastAll

Privacy & Terms