And what would you do with the rotated vector?
We still need an alternate target for the zombie, so that it doesn’t just stand still, trying to attack a player behind “diagonal vehicle forcefield”.
There could be some different solution, but casting a ray and considering attacking the second and third tile of it would be a relatively simple solution.
Just interior/edge/exterior wouldn’t be enough. Consider the case:
| | |
| @ |
z | .
'z’ombie is standing on a non-vehicle tile.
Depending on the implementation:
[ul][li]“Diagonal edges” are still edges, so the zombie can attack the player (who is occupying an edge tile). When the vehicle rotates, the player can always be attacked if adjacent to a zombie in global coordinates.[/li]
[li]“Diagonal edges” are interiors, so the zombie can’t attack the player, despite vehicle not being rotated and player being adjacent to the zombie[/li][/ul]
Example of the “player can always be attacked when adjacent in global coords”:
. | | .
. | @ |
z | | |
Rotated to:
| | . . .
. | @ | .
. z | | |
The lack of the tile diagonal to the player would cause the tile on the other side to be valid to attack from.
And once again, we still need that ray in some cases, because “can’t attack” isn’t a good enough answer, we need “so what should we attack instead?”.
So the neighborhood information would only allow skipping the un-rotation check (relatively cheap operation).
Optimization isn’t all that important in zombie vs. vehicle attacks. Could be nice to have, but a simple, easy to understand solution is more important here, as car bashing doesn’t happen all that often. And when it does happen, it’s usually an unrotated car which is attacked, so the idea for implementation in my post above would be quite fast (distance would always be 1, no rays would be cast).