How would I make planets seem further than they are

Introduction

So I am currently working on a space game, and a big problem that I have run into is floating point error. As you know, space is massive, with planets being millions of miles apart. Obviously, this is impossible to replicate in ANY game engine, however, you can create the illusion that it is happening.

The current system

The ship has two modes: normal and subspace. Normal allows the player to travel up to 450m/s, and subspace allows the ship to travel at up to 16 light seconds per second. As you can guess, the ship is not actually traveling at 16ls/s, it is more like 10,000m/s, but by making relatively ‘small’ things (such as space stations and other random parts) disappear when the player enters subspace, it creates the illusion of going extremely fast.

Now, planets are 50k to 100k studs away from 0,0. When the player is in Normal speed, the planets move away from the ship at the same speed as the ship is moving, which makes them think they aren’t getting any closer at all, and when they enter subspace, the planets go back to their original position.

The problems

Let's say that the player has moved ~25,000 studs away from 0,0 in normal speed. That covers half the distance to a planet, but to the player, it looks like they haven't gotten any closer at all. But as soon as they enter subspace, the planet jumps back to its original position, which looks terrible.

If the ship travels another ~15,000 studs towards the planet and then exits subspace into Normal, the planet will start to move away from the ship at the same sp eed at which it is moving, once again creating the illusion that the ship isn’t getting any closer.

But if the ship travels another ~10,000 studs in Normal, it has technically reached the planet, however to the player, it doesn’t look like it. And if the ship then enters subspace again, it will be inside the planet, which makes it look like the planet just disappeared from the player’s pov.


An extension to this problem is the fact that the game will be multiplayer, and from other players' pov, it would also look like the player just went inside the planet.

Code/Videos

https://youtu.be/VIEAz2s_wYU

My code if anyone is interested:

local Bodies = {}
for i, v in pairs(game.Workspace.Bodies:GetChildren()) do
	table.insert(Bodies, v)
end

local player = game.Players.LocalPlayer

local shipValues = require(script.Parent:WaitForChild("ShipValues")).shipValues

local userSettings = UserSettings().GameSettings

--How each quality level should effect the positioning of planetary bodies
local distanceConstantSettings = {
	QualityLevel1 = 170;
	QualityLevel2 = 340;
	QualityLevel3 = 510;
	QualityLevel4 = 625;
	QualityLevel5 = 725;
	QualityLevel6 = 170*6;
	QualityLevel7 = 170*7;
	QualityLevel8 = 170*8;
	QualityLevel9 = 170*9;
	QualityLevel10 = 170*10;
}

game:GetService("RunService").RenderStepped:connect(function()
	for i,v in pairs(Bodies) do
		local graphicsSetting = userSettings.SavedQualityLevel.Name
		local distanceConstant = distanceConstantSettings[graphicsSetting]
		if (v.Looped.Value == false or shipValues.subspace == true) then
			v.CFrame = CFrame.new(workspace.CurrentCamera.CoordinateFrame.p+(v.OriginalPositionConst.Value-workspace.CurrentCamera.CoordinateFrame.p).unit*distanceConstant)
			if (v.Looped.Value) == false then
				v.FakeOriginalPosition.Value = v.Position
			end
			v.Looped.Value = true
			local Constant = (v.OriginalPositionConst.Value-workspace.CurrentCamera.CoordinateFrame.p).magnitude/distanceConstant
			v.Mesh.Scale = v.OriginalScale.Value/Constant
		elseif (v.Looped.Value == true and shipValues.subspace == false) then
			v.Position = Vector3.new(v.FakeOriginalPosition.Value.X + player.Character.HumanoidRootPart.Position.X, CFrame.new(workspace.CurrentCamera.CoordinateFrame.p+(v.OriginalPositionConst.Value-workspace.CurrentCamera.CoordinateFrame.p).unit*distanceConstant).Position.Y, v.FakeOriginalPosition.Value.Z + player.Character.HumanoidRootPart.Position.Z)
		end
	end
end)



I would greatly appreciate if anyone has a solution/idea on how to go about creating this planetary travel system.
1 Like

What about just resizing the planet models depending on how far you are? It shouldnt be hard to come up with formula which would calculate you the needed radius of the planet depending on you distance if you have some size constant for it already

I have thought about this, but when you get within like 1000 studs of the planet, you would realize that it is very small, and you would eventually go past it.

umm, then simply simply dont resize it when the player crosses a preset distance, and use the resizing only as something like interpolation between the “size jumps”

But then that just causes the original problem again, where if the player goes too far, they will end up inside the planet

it doesnt, just check if the player is closer than the smallest constant, and if its true, then dont interpolate the size?

But how is that supposed to fix the problem of making the planet seem the same distance away? Once I stop changing the scale, the planet will start getting ‘closer’ again.

in that case, make it unable for players to “end up” in the planet. Like exploding their ship or something. Maybe I dont understand the issue

i would set boundaries that can only be passed using subspace. like physical walls which prevent the player from completely reaching a planet before it looks like they have arrived it.

I may not have explained my code that clearly. Basically, one part of it is moving the planet close to the player based on their graphics settings. I do this because for low graphics quality players, planets more than ~50,000 studs away disappear. So what I do is shrink the planet and move it closer to the player, and then as the player moves in subspace, gradually move the planet back to its original position and size.

However, in Normal speed, I don’t do this, and simply just keep the planet a set distance away from the player, without changing the size, which causes the issue that I stated in the original post.

I’ve seen that solution before, but I would rather not do that as it ruins immersion.

then istead of physical boundaries, add something like a warning that indicates to player that he is too fast and needs to change into the subspace nav. or else their ship would crash into the planet or sum

But how would this be explained to the player? And it once again ruins the immersion of an ‘open world go wherever you want’ type game.

I dont think it would ruin the immersion, actually I think its the opposite. You cant fly so close to planet at high speed without getting totally ripped off my atmosphere or something. Also I dont think this can be explained to the player without some kind of tutorial, and after that, a red warning text would be fine for them to be reminded that they are doing something wrong.

I like the idea, but it isn’t the effect that I am trying to achieve. I am trying to make it seem like the player isn’t getting any closer to the planet at all, as they are only going at 450m/s.

hmmm, I aint really sure, I think some kind of illusion would be need for it, since you cant scale the planet realisticly. So the only thing that comes to my mind is to make the player’s ship much much slower when this close to the planet, so much that it does the effect of enormous planet. I dont have any more idea though

Oh ok, I appreciate the help though! Hopefully, someone else comes along with some ideas.

What i’d suggest is moving the ship back every time it travels a certain distance.
Of course for this to look seamless you need to make the random parts around in the space replicate in the beginning and in the end, kinda like animating a character walk

2 Likes

I like this idea, the only problem is how to make it look seamless and smooth from the pov of the player

1 Like

Honestly there’s no perfect answer except making huge planets.

You could get close to what you want using scaling and other stuff but it’d be far from realism and probably also mess the multiplayer system.