World Edit Tool
Hey folks!
Today, I delved into enhancing the map editing tool for my game. To begin with, I utilized OnDrawGizmos to paint a square where the mouse cursor hovers. This serves a dual purpose: visualizing the tile I'm interacting with and confirming the accuracy of coordinate transformations from screen to world space. Given that my game features a 3D map, incorporating mouse scroll functionality to adjust height is in the works.
While testing, I noticed a slight offset of 0.5 units in the cube I placed to confirm world positions matched the grid. This discrepancy stemmed from Unity's cube having its pivot at its center. To rectify this, I'll ensure the pivot aligns correctly beneath future 3D elements.
Additionally, I introduced a GUI to toggle into edit mode and display various map editing tools. Currently, options include painting, erasing, saving, and clearing the entire map.
The painting functionality needs spawning objects tied to specific tiles. For this, it's crucial to understand my tile system. Tiles are stored in chunks, each comprising a 16x16 grid. Utilizing dictionaries ensures efficient coordinate-based tile retrieval. Furthermore, tiles are subdivided into a 3x3 subgrid, simplifying interaction logic.
Next on the agenda is implementing a tool for removing elements from tiles. Given that tiles can contain multiple objects, precision is key. I'll devise a method to retrieve and delete all objects within a subgrid quadrant, granting finer control over world object deletion.
Enabled by visualizing the target tile, creating the painting tool and object spawning became straightforward, although a lack of preview functionality is currently overlooked.
Midway through development, I pondered how to impose placement restrictions on objects. Walls, for instance, cannot overlap, whereas rugs pose no such hindrance. I'm devising a solution: a class called "PlacingRule," designed to encapsulate placement logic. These rules, applied to object information tables, ensure compliance before object placement.
A cautionary reminder: correctly mark your variables with [SerializeField] and [NonSerialized] attributes for proper serialization. I wasted two hours troubleshooting data loss before realizing some objects weren't serialized due to improper marking.
Stay tuned for further updates as I tackle these challenges and push my project forward!
Get Z-Engine
Z-Engine
Status | Prototype |
Authors | Argendel, [Random Adjective] |
Genre | Survival, Simulation |
Tags | building, Minecraft, Sandbox, Singleplayer, Top down shooter, Voxel, Zombies, zomboid |
More posts
- Graphic StyleJun 08, 2024
- Personal InventoryMay 25, 2024
- Inventory SystemMay 17, 2024
- VerticalityMay 08, 2024
- XRayMay 06, 2024
- FOVMay 02, 2024
- Colliding WallsApr 30, 2024
- MiniaturizationApr 26, 2024
- First ProblemsApr 24, 2024
Comments
Log in with itch.io to leave a comment.
The grid display system is only for the editor or will it be part of internal tools in the video game?
Hi, I was planning to add this only for development purposes, why?