Closed andrew-peng-144 closed 3 years ago
Can use multiple grids. For efficiency only check between categories that need to be checked. (can't do 3 way collision this way but oh well). So can have a grid only for player projectiles vs enemies. idk.
Maybe multiple grids is not necessary. Old method with 2500 checks still allows good freedom with alright performance. Trying to define categories and interactions between two categories may be more explicit and clean, but will end up being slower if too many groups are defined anyway. And having less freedom includes it being harder to query an area of the world at anytime because it will need to check all grids?
can still incorporate categories/types for pc's, so when handling collision it will first check the category then branch accordingly. Lots of if statements will be executed tho.
Or cleaner, use the proposed idea a bit, by having a system where you only define interactions between two types. Won't be slower with many defined interactions, unlike the proposed, which has grids for each interaction. can be some handler object, with method handleAB(typeApc, typeBpc), a unique method for each interaction. It is called when the gridcell sees two pc's with those 2 types, only once for each combination. and that method can cleanly handle exactly what to do when that combination occurs.
the unique handle method method will have high coupling lol, but uh, it is more straightforward, and most game engines use something like that anyway. Before choosing which one, should study how others use it like godot and unity.
STO PTRYING TO COME UP WITH NEW MODELS, JUST COPY THE POPULAR ONES LOL, if its popular then its probably practical!
need easy way to detect collision between categories. And clean collision resolution, i.e. noninterfering with the normal flow of logic. then can start combat!