You can usually make anything in Roblox studio, but to my knowledge fog of war cant optimally be made with the tools currently available. I know games like territory-conquest have a fog of war system, but that system is fairly simple as it shows you what you border unlike the average RTS that show all units and building views. Basically my question is, how can a Fog of War system be made similar to Command & Conquers Fog of War, (if it can be made).
Can you add picture of the effect you want? Otherwise I don’t know what you want or are talking about.
If you are talking about having fog limited to certain regions (as in real life) then I would make some mesh parts and mess with their transparency. Then whenever a player goes in that region a local script changes the skybox to a flat greyish color and sets the fog to the same color as well.
On roblox you would have to render and de-render parts of the map yourself.
Sure, it’s possible. How good does it have to look?
Slap some big white bricks down that cover the obscured areas. Done.
Fully visible = You can see everything moving around etc
Foggy = You were there but now you aren’t. and wont be able to see any movement there
Unknown = You cant see anything in there and you haven’t been there
This is accomplishable with Region3 | Roblox Creator Documentation or checking the players position with (HumanoidRootPart.Position - RegionBorderPart.Position).Magnitude
. However, in this situation I’d say that Region3
is the way to go.
well, make some 0.5-0.7 transparency black blocks??!???!?!??!?!
easy and simple, but idk why people are talking hard stuff
would I have to constantly check for each player owned unit right?
Its not that simple. They cant just be permanently invisible, when you send a unit into the black fog the fog would have to become fully transparent.
…well delete the block when player touch it ;-;?
You could use an Atmosphere or adjust the Fog settings under Lighting. Those aren’t perfect solutions though. What you might instead do is create some black walls out of Neon parts or something and automatically place them around your grid on the client. This is effectively what the game above is doing.
You could also hide objects outside of the visible area, and, place black tiles in hidden areas for example.
There are plenty of ways you could do this, and, there are a lot of options.
For the foggy area, you can darken those areas in similar ways, and, just hide anything outside of the range of that area.
The game you posted a screenshot of above uses a tile system, and, usually that’s what I’d recommend for FOW, since, you can much more easily decide on different shapes than circles or spheres. You can mark each tile as unknown, hidden, or visible, and then for any objects within those tiles you can show or hide them.
Whenever a tile is made visible, you just find anything on that tile and show it, and, optionally hide any fog parts on that tile that border visible tiles.
or you want only a area of it to be visible
Cant be deleted, as the player could leave the territory soon after. Also keep in mind its not just the player im checking for, its his whole army.
You could make use Workspace | Roblox Creator Documentation and have all the parts already in the region on the ignore list. Then iterate through the parts returned and use Players | Roblox Creator Documentation on their parent. If the function returns a player you can then have the fog, current, and unknow areas change for the players client via by communicating with their LocalScript | Roblox Creator Documentation via a RemoteEvent | Roblox Creator Documentation.
Ill look into both responses you two gave me, Thanks
If you want to account for the players army you can use CollectionService | Roblox Creator Documentation and CollectionService | Roblox Creator Documentation to check if the part is part of the players army.
note that i did not test this out so there might be some errors
hmm…sounds easy to me, just make a script inside the block and write:
local part = game.Workspace.Part
if part.Touched:Connect(function(hit) then
part.transparentcy = 1
else
part.transparentcy = 0.6 --or whatever you want the part transparentcy be before it become 1
This isn’t what they asked? They simply asked if it is possible to make different regions of fog and hide parts in them. This is possible with a Region3
btw @OP.
Also:
- Please use indentation in your code. It makes it so much easier to read.
- You spelled “Transparency” wrong which would error the script.
- You forgot an
end
at the last line of your code.
Btw I’m not criticizing you or anything, I’m just pointing out some mistakes that could cause others to be confused.
“If only there was a way to make a fog of war in Roblox like in C&C…”
The fog of war in Roblox in question:
- Yes it can be made.
- Yes, it can be optimized to be performant.
- You can even create a minimap for it.
I’m reviving this thread because this is crucial information for any upcoming RTS games on Roblox and the OP didn’t get a full answer. All of the answers before were to a certain degree helpful, but they either never mentioned how to actually introduce the “fog” part of the fog of war, or they relied on the literal fog object that Roblox has, which at least to me is unsatisfactory for many reasons. Mainly, this fog is relative only to the camera, which means that you wouldn’t be able to reveal two places at the same time, only one. Second, the fog doesn’t look like in RTS games, for instance:
Shaders.
In other engines, like Unity, you can use shaders to create a fog of war (by applying layers onto the terrain), which can look identical to fog of war in games you’ve mentioned, like Command & Conquer franchise, from the first 2D games to the newest (but not new) 3D ones. Here’s a problem, as you’ve probably noticed, I said other engines:
There are no conventional shaders in Roblox.
Not any that you can use to apply a specific texture and special effects to parts. For that, you need to create your own. Here’s how I made my own, and made it quite performant.
I created a world made out of tiles (4x4x4 I believe, but it can be any other size) and when I was finished, I ran a command in the console to darken their colors by ~30%. I then created a system in which parts, which I refer to as “Detectors”, detect those tiles within the defined radius of them.
I made two tables, one for the tiles and other objects that were outside of the detection distance of all detectors combined, and the other for those objects within their detection distance.
Every tick, the detectors checked if they have any new tiles in range, if they did, they recolored them by giving them back their original color. Then they checked if any of the tiles that they previously had are still within range. If they aren’t, they’re put in the first group and are darkened.
It’s a bit different for units, if they’re outside of range, they become invisible, and once they come in range of any of their parts come in the detection range of the detectors, the whole unit becomes revealed to the detector in question.
This system works quite well as you can see in the topic I linked above, and it can even be connected to a minimap system that’s also inherent in the RTS genre.
I hope this helped whoever is reading this. If there are any questions, be sure to ask, I’ll try to answer them.
Source of the video: