Hi, I am working on a game where one of the main features of the game would be the ability to land in a planet’s atmosphere and being able to explore (albeit limited) on the surface of the planet.
However, how would I go about doing this?? The current build I have been experimenting with has been with meshes and decals, but is there any other way? Is it possible to have a localized sky-box within the planet that can convey an atmosphere of some sort? The current one I have right now does not look good at all and is made with a mesh. Below are pictures of the outside and inside of what I currently have. I feel like it looks really outdated right now.
I have made something like this before but the sky only has a solid color and its transparency depends from where the player’s camera is
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local FakeAtmosphere = ReplicatedStorage:WaitForChild("FakeAtmosphere"):Clone()
local Planets = workspace.Planets
local Camera = workspace.CurrentCamera
local PlanetsWithAtmosphere = {}
FakeAtmosphere.Parent = workspace
function Distance(A: Vector3, B: Vector3)
return (A - B).Magnitude
end
function NearestPlanet()
local NearestPlanet, NearestDistance
for _, Planet in pairs(PlanetsWithAtmosphere) do
local Distance = Distance(Camera.CFrame.Position, Planet.Position)
if Distance > 100000 or (NearestDistance and Distance >= NearestDistance) then
continue
end
NearestDistance = Distance
NearestPlanet = Planet
end
return NearestPlanet
end
local function GetValue(x: number , Min: number, Max: number): number
local range = Max - Min
return math.clamp(1 - (x - (Min)) / range, 0, 1)
end
for i, Planet in pairs(Planets:GetChildren()) do
if Planet:IsA("BasePart") and Planet.Data.HasAtmosphere.Value == true then
table.insert(PlanetsWithAtmosphere, Planet)
end
end
RunService.RenderStepped:Connect(function()
FakeAtmosphere.CFrame = Camera.CFrame
local NearestPlanet = NearestPlanet()
local PlanetModel = Planets.Model:FindFirstChild(NearestPlanet.Name .. "Model")
local AtmosphericData = NearestPlanet:FindFirstChild("Data"):FindFirstChild("HasAtmosphere")
FakeAtmosphere.BrickColor = AtmosphericData.Color.Value
local Range = GetValue(Distance(Camera.CFrame.Position, NearestPlanet.Position), AtmosphericData.Start.Value, AtmosphericData.End.Value)
FakeAtmosphere.Transparency = AtmosphericData.Density.Value / Range
PlanetModel.Atmosphere.Transparency = Range * 2
if Range > 0 then
FakeAtmosphere.Transparency = 1
end
end)
End meaning the distance from the center of the planet to where the atmosphere should end
and Start basically meaning where the atmosphere is at its fullest (from where the surface is from the center aka radius)