Hello once again mates !
I have wondering what would be the best method to do 2d grid placement system, for example like in this game Legion TD 2 - Multiplayer Tower Defense Gameplay (PC UHD) [4K60FPS] - YouTube.
What are my ideas, and what have I tried as a whole for now.
Export blender grid meshes on places where we want towers to be placed ( make plane in blender, subdivide it and make copy, place it near other, that gives you control over placements if you have predefined towers for example)
- Each element is for itself and you have control over each grid element
- You can create standartized template, and use grid logic to read and easy apply predefined functionalities
- More complex geometries
- If you have 5-6 big grid systems you will always load all verticies. ( you cannot for example say to load 1,2 as it is if we dynamically generate them with code )
- We must check alot elements each frame for overlapping ( when user have selected tower, which may be performance killer, instead of smooth experience )
- We don’t have full control of width/height, every time when there is a change, add or remove of grid we must go in blender and do it…
Make TIle map in babylon
- We have control over width/height/placement/ number of grids.
- We load won’t load unnecessary verticies, always ( for example if max players that can play the map are 10 and we have only 3 it won’t load all grids)
- Harder to create/ manage
- Act as a one whole unit ( atleast I still cannot do it to recognize each square for itself ).
What exactly is my idea from the tries that I have mentioned up.
When map is loaded, we will scan the number of users and get random ( for now ) poitnts and parameters for creating grid system on given place with given height/width/ squares numbers from object.
- User Gui loads and user clicks on button to choose given tower, we are making active the grid and adding raycast on mouse cursor.
- When it intersects with the grid, we are calculating (1 tower should be placed on 4 squares, still not sure how to calculate it…) if tower can be placed on that spot (eg. tower are intersecting with another tower or not fully into the grid)
- User clicks and mesh is added to position of those 4 mesh squares.
- Will the main idea work ?
- Is it better to make predefined grid in blender, or go and keep trying my main idea ( generate grids from predefined parameters after map load ) ?
- Any idea how to calculate sibling squares if there is some obstacle which prevent tower from being placed there ?
- If there is a book/ forum or anything for those kind of systems can you please share it ? ( internet is full of information for different kind of grid systems and I am confused at the moment )
Thanks in advance ! Have an awesome day !