0
\$\begingroup\$

I want to create a 3D Top Down Battle Royale game in Unity and wanted to add a mechanic to color the floor, walls and ceiling, just like in Nintendo game Splatoon.

I know that you can color a 3D shape using materials, but as far as I know, that only works for the entire shape, and I do not want to create a seperate cube for every metre that can be colored.

Maybe you can do this with a sprite mask, but I am not sure how this works and I do not know if this is even a thing for 3D games.

Any help is highly appreciated since I am quite new to this website and to Unity as well.

\$\endgroup\$
2
  • \$\begingroup\$ For a few, you could use decals. But I'm not sure that would be performant enough for a Splatoon like game. You would need as well still figure out how much is actually covered for winning conditions. \$\endgroup\$
    – Zibelas
    Apr 10 at 8:04
  • 1
    \$\begingroup\$ See also: How can I make a "paint" effect? \$\endgroup\$
    – DMGregory
    Apr 10 at 11:57

2 Answers 2

0
\$\begingroup\$

Fun fact, this technique is older than Splatoon, it is present in Super Mario sunshine.

You will need an extra texture over the entire paintable battle field.

Then on collision of a pain splat you can map the collision point to that paint texture and then you fill it in with the pattern of the splat. Making sure to account for the edges for either overflow to other parts of the texture and limits.

You can also use this texture to add effects for the players (like struggling in enemy ink or diving down in own ink).

Then at the end of the match you can count the pixels of each color.

\$\endgroup\$
1
  • \$\begingroup\$ Unity's lightmapping system can automatically generate unique UVs for all the static geometry in the scene, which can help with this. \$\endgroup\$
    – DMGregory
    Apr 10 at 10:57
0
\$\begingroup\$

You would use a textured plane mesh, not a quad. You could use a large plane mesh with a single large texture which you update parts of in CPU-side code (this can be done in Unity). Temporary decals would be a bad idea for this, due to an unlimited number of them, so you have to modify a base texture permanently to avoid that problem.

Networking and throughput rates

You didn't explicitly ask about this, but if your game needs networked multiplayer, you need decent data transfer rates. A naive design that works on a single client may not suffice for network. You'd probably need a lossless form of compression, to keep the game fair.

I suspect compressing as PNG would be one reasonable way. PNG performs extremely well for this purpose, i.e. run-length encoding of a limited number of colors. You decompress the PNG data when you need to work on the texture data, and recompress it when you're done. Can send the PNG as-is over network, to render as texture on the other client (Unity supports PNG textures).

You could also go with a multi-PNG grid approach, where you compress an even smaller part of the overall texture for sending to the other client. Divide the overall texture space into a grid, let's say 8x8 cells. Now, if a splat lands in the top left corner of the grid, you only send 1, 2 or 2x2 cells around that splat (cells would generally be around the size of a splat, maybe slightly bigger, this way it will never be more than 2x2 cells changed per player shot/splat). This leaves you having to decompress the smaller PNGs and reintegrate them into the large PNG used as texture during play, once they are received on the other client's system.

For more extreme compression, try a binary / 1-bit memory-contiguous sparse quadtree. Each bit represents color A(0) or color B(1). You would compress to quadtree from raw (2D array) data each frame you need to send it, then decompress it to 2D array / texture once it reaches the other client. A sparse quadtree also requires a lookup table to read from it (or you can't know where each node is located), but it can be extremely small. This uses considerably less bandwidth than the PNG method, because (a) it compresses in 2 dimensions as opposed to PNG's 1 dimension, and (b) is using individual bits rather bytes to represent color A or B (8x smaller per color "patch").

The final option is having a fully deterministic physics simulation on each client, in which case just receiving the inputs from each player is enough to reconstruct exactly the same splattering results on each machine, every time. Very cheap but harder to achieve deterministic physics.

\$\endgroup\$
2
  • \$\begingroup\$ In Splatoon, vertical walls are an important part of the game, so a large texture based on planar positions are not suitable. It might be a solution to have all paintable objects apply a paint material and package the textures into a large atlas. \$\endgroup\$
    – Mangata
    Apr 12 at 7:21
  • 1
    \$\begingroup\$ @Mangata I think that is fairly obvious, don't you? A texture per wall or, as you rightly state, an atlas are required. We are talking about the fundamental solution here, not all the details. \$\endgroup\$
    – Engineer
    Apr 12 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .