- Home /
Passing Underneath Section of a Mesh
Hi all, I've been trying out submeshes for Tiling with different materials (texture) since it keeps thing nice and clean with just a single GameObject , but I couldn't get the mesh or submeshes to behave like what I wanted when a character passing over certain tiles.
These are the following layout of camera and playable character:
Camera is set at z-level: -10 (default)
Player is set at z-level: 0 (default on creation of gameObject)
Any gameObject that has z-level of -1 would be on top of the player since it closer to the camera relatively speaking while any gameObject that has z-level of 1 should be beneath the player as it further away from the camera.
Since that is the case, I set all ground tiles to be at z-level of 1 while roof tiles should be at -1. While this worked as individually gameObject per layer - that is ground tiles occupied one gameObject with mesh while roof tiles occupied a similar gameObject - it doesn't work when ground and roof tiles occupied the same gameObject via submeshes,
In the combined mesh so the entire tile map uses a single GameObject:
All the vertices of Ground tiles are at z-Level: 1
All the vertices of Roof tiles are at z-Level: -1
There are a lot more ground tiles than roof tiles (obviously).
The player is at z-Level 0, so if I move the player over a roof tiles, the roof tile should render on top of the player. In contrast, the ground should render underneath the player as it further away from the camera. At the moment, they rendered underneath the player, making the player to walk over the roof section of the map ... o_O
It seemed that the Camera doesn't compensate for different z-levels of a single (disjointed) mesh, or that a disjointed mesh has a net-worth/average z-level?
If that is the later case, how do I tell Unity to take into account of dynamic height differences and render them correctly from their position to the camera? Any helps or pointers is greatly appreciated.