Why "<" as opposed to "<="?

Quick question about our AimWeapon() method in TargetLocator-

At 10:08, why are we using “less than” instead of “less than or equal to”? Since if target distance is equal to the tower’s range, than it is still within range. Figure it doesn’t make much difference but just curious.

Great spot @idanickim!

You certainly could (and probably should) use <= instead of < for this distance check, so feel free to adapt your code accordingly.

Since we’re storing the range value as a float, the difference between the two is negligible.
However, if you were using something like an integer instead then that difference would definitely become much more noticeable.

1 Like

Got it, thanks!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms