Download

Walking inside a space ship while it is moving at high speeds

Hi everyone!
So this will actually be multiple questions and I’m afraid some of them will be a bit tricky.

So, here is my plan:
The concept is that the game is a multiplayer game and each player acts as a crew member on board of a large space ship.
You don’t actually control the ship itself, you control a character and you are able to walk around freely on board of the ship and use cannons, steering devices, etc.
Now the problem is how to simulate the actual movement of the ship.
If I simply move it with an AddActorLocalOffset node the player actually moves along with the ship just as he should but once the ship reaches a certain speed the physics start to get wacky and you glitch out.
The lighting rendering gets ugly, too. I’m talking about really high velocity here but unfortunately space ships tend to be really fast.
Theoretically, I could try to just have the ship stand still and make everything else move instead but I would like to make it possible that other players can be on board of and fly other ships as well and then that would become a problem.
So, do you have any ideas how I could perform the movement of the ship so that the player doesn’t glitch out of it? Can you maybe attach the player to the ship so that he always stays in place but can still move around with inputs?
And any ideas how to simulate the high speeds without messing up light rendering?

Another issue I have encountered is the rendering distance. Obviously, rendering a star that is a million kilometers in radius and two million kilometers away is not a possibility.
But if you want to be able to move around freely in space you could also fly close to a star’s location.
Is there a way to increase the rendering distance of an object to such extreme extents (with a super low-poly LOD, of course) or is it better to somehow fake it, e. g. by simply putting it in the material of the sky sphere? But even then it would eventually have to switch to an actual object at a certain distance and that distance would probably still be too far in order to be renderable. And the object would be huge. (By the way, would the massive size of the star have an effect on performance even if it is low-poly and low resolution? Meaning: Does scaling things bigger affect performance?)
Eve Online can do it too. :wink: How does CCP handle it? :smiley:

And last but not least, is there a limitation as to how far away from point 0,0,0 the player should move?
As you can guess, it would be insanely far in this game. Would it maybe cause performance issues or bad rendering or physics calculations?

I am not yet very familiar with UE4 yet and I am aware that those are quite advanced issues and not really suited for a beginner like me.
But I am more of a game designer and less of a programmer or techie and this is just a private project I’ve had on my mind for quite a while.
I’ve been collecting a bunch of gameplay ideas for this for a while that I really liked and I just want to give it a try.
I could do it in Unity but the physics engine there would probably cause me to glitch by the time the ship hits the speed of a granny on a bicycle. And I probably would encounter the same issues anywhere.
And sorry for the wall of text. :smiley:

Personally I think having the ship moving fast is too risky. Best to have the ship be still and have “everything else” moving. Other ships moving are not an issue, they just have to be moving ~relative~ to the primary (still) ship.

I’m no expert but from what I’ve tinkered with Unity and Unreal you probably don’t want to have the ship and all the actors, devices, etc. on board flying around at high speed relative to 0,0,0, you’d want to save your physics budget for other stuff.

You’d also have to consider volumes, post-process, dynamic lighting etc, that could be parented to the thing moving at high speed but you’d probably not want all that child objects to be flying around at high speed millions of units away from (0,0,0).

The scaling thing is a good question. It’s mind-boggling because it’s not the actual size relative to the player that matters. From what I’ve learnt it’s the LOD, then it’s switching between a massive low poly thing in the background and/or “skyspheres” etc.

Remember that the “render distance” (far distance culling in Unity) should not be physically accurate, it just has to appear that way. That is, in real units the star maybe light years away but in game units a “cheat” would be done ie. it wold be closer so that it falls within the draw distance but adjusted visually so it makes sense.

Again with the star, let’s say the ship is approaching this star, you would I think move the star closer (and adjust LOD accordingly) not move the ship towards the star. With the star, you wold move the star closer and scale the star up to simulate the vast distance travelled to get to the star.

Unless you’re making a super-physically-accurate simulation I think the standard game “cheats” would apply.

Don’t forget fancy particle effects (streaming “stardust”, lines, etc.) to simulate movement of the ship (even though the ship is technically stationary).

My 2 cents :slight_smile:

Yeah, there’s probably no way around faking it.
But let’s say there are two space ships controlled by players. They are both going in opposite directions at max speed. Even if I fake it with all kinds of effects it would still have to be pretty fast movement in order to look plausible.
I noticed that even very low movement can already cause the player to glitch (I’m talking about speeds like 20 mph).

Is there a better way (better for physics) to move the ship than using AddActorLocalOffset?

You will probably want to take a look at this blog post. This might fix some of the physics issues.

As for the best way, AFAIK, Star Citizen handles it by having multiple physics ‘scenes’, one for the world and one for the interior of each ship. This allows the ship’s movement or position to not adversely affect the calculations for the interior physics. I don’t think(would be quite happy to be wrong) this is possible in UE4 without modifications to the engine source. If you have 4.7+, I would recommend taking a look at PhysScene.cpp, and the physics related files in Source/Runtime/Engine/ (in your engine directory).

EDIT: Also the phAT source, it creates a separate physics scene. Might not be too utterly difficult after all.

For handling a large universe, or even something the size of a solar system, I have no idea how to accurately simulate the distances involved. It gets even dicier when multiplayer is involved, too.

I would definitely look up as much material as you can find on the inner workings of KSP and Star Citizen. While neither are using UE, it will still give you a jumping-off point to work from(or to).

Very interested about where you go from here, this idea is very close to something I have wanted to build for a long while.

As a note: I think UE4 uses a technique that allows them virtually infinite render distances. The main limitation is that the near clip plane is the driving factor in how far you can see without errors. With a NCP of .1, you start seeing major scene depth issues ~200-500 meters out. With a higher NCP, say 5 or 10, said errors happen at such large distances that they are nearly unnoticeable. If you go View>Buffer Visualization>Overview, your viewport will show all the buffers rendered in the scene. The scene depth buffer controls how faces get drawn and the order in which they are drawn.

I’m afraid that would be a solution that would exceed my programming skills.
I can’t find many details about how Star Citizen and KSP handled it anyway.

And I tried to use CCD but it doesn’t seem to make any difference.

I think I’ll keep working on this idea as a co-op game. Meaning that all players are on board of one ship. The ship could stand still and everything around it could move.
But as soon as other players can be on other ships I have no idea how to solve that.

From what I know, CCD just means that every frame(or physics sub-step, even worse) it checks for collision, consuming CPU time. A tip: don’t enable it on projectiles. I tried that once, with about 20-30 projectiles in the scene my fps went down by half.

Having everything outside of the ship move is probably a good idea. I would (theoretically) use a combination of movement and scaling of environment objects to simulate high speeds.

Poke around on the wiki a bit; the Solus example project had some pretty big (mesh) moons in the sky, you might learn a few things.

I am not a smart man.
I forgot that I had a black sky sphere in my scene with a few stars on it that was hiding the planets when they were behind it. I deleted it and now the objects are actually visible at insane distances.
I just made spheres representing earth, moon and the sun and they are actually visible at the real distances and real sizes. I’m impressed. A 695,800 km radius sphere at 149 million km distance and it’s still rendered correctly.
I’m just not sure if it’s a smart thing to do. And I would like to have a sky sphere anyway. Is there maybe a way to mask objects in the sky sphere material so that they are still rendered in front of it even if they are actually behind the sky sphere?
Actually, no object should ever be covered by the sky sphere. Is there a way to have the sky sphere always rendered behind everything else?

I don’t think so. Not without heavily modifying the engine’s render code, at least.

Best I can come up with is a really, really huge sky-sphere. A Set Actor Scale node with a value of 10,000 or so in the construction script of an already large skybox might do it.

Also, as it turns out, there is a function in the UWorld class for world origin rebasing. The only thing calling it by default is the World Composition system, but I think it should be pretty easy to implement a user-controllable system to call it. That would allow players to move long distances(say in eva, or external ships) and not run into floating-point precision errors. It would require a bit of fancy maths to work in multiplayer, though.

This may provide you with some ideas.

I’ve tried a work around on this for a game idea quite similar (you control the ship and fix broken things in it). My idea was to have the ship stationary and have the render-texture to represent everything outside the ship. The ship itself is a small actor that has said camera’s on it that feed back to the textures.

I know source can do this (portal walls make this very easy) and I have played a tech demo of UE3 doing the same thing, but have no idea how to set it up in UE4.

I could be wrong, but could it not be done using some kind of instanceing? That way you’d have the best of both worlds; the primary ship is stationary because all of the primary ship stuff is actually in an instance, but the instance of the primary ship is parented to an actual moving ship exterior. If the player were to jump out, they’d effectively leave the ship instance and have to be calculated normally. I know people did some pretty crazy things with the instancing in the source engine when Portal 2 introduced that.

Perhaps you could do it by cleverly switching between a stationary ship and an actual moving one? I mean, say the player walks into the cockpit or bridge to fly the ship. When the door behind the player closes, you could switch the player into an actual dynamic ship which hasn’t got to worry about actually rendering the interior at all; the only physics objects to calculate are the ship and the player. Then when the player walks back into the rest of the ship, you put them into a fake ship. Hell, the old (pretty terrible) source engine method was to use Render Targets to make fake windows in the stationary ship. The cameras would be attached to where the windows would be on the real ship, and then you’d have a TV screen showing the exterior view instead of a window. That could be a more viable way to “cheat” this kind of thing.

Sorry for all of the imprecise “ideas guy” non-technical speak, I’m still pretty inexperienced with UE4.

Thank you so much for your ideas!
I’m still not sure which solution to go for. It would make sense to just move everything but the player’s ship but you would also have to make everything, and I mean really everything, including other ships, planets, stars, asteroids, projectiles, etc. move and also rotate around the ship. Now if you want to have multiplayer all of this would need to be handled independently on each client because other players would need to be moved around in my client but from their point of view they are standing still and I am the one who needs to be moved around. And I would definitely need a quite experienced programmer for that.

I’ll try the “fake window” solution as it sounds easier. Maybe I could just “hide” the ship somewhere and have an exact copy flying around with cameras attached instead. That would mean that other players could still see your ship even if your character is actually in a copy of your ship somewhere else. That only has the disadvantage that I could probably no longer implement the planned feature that you can destroy other ships’ walls and have their crew sucked into space. But I can’t have everything, right? :smiley:

Well, that’s not going to work either.
RenderTargetCubes are just too heavy on the performance. The resolution of the target render needed to actually simulate windows would just be too high.
I’m starting to get frustrated. There must be some way to do this.:mad:

There is, folks from AFF did it in UDK and it works very well. They used some tricks with camera and render to texture.

You do not need to render all windows all the time, script in some optimization.
For eg, render every window at begin play, then update one window (or one side) every second or 1/10th if they are not in view. And just loop through all of them.

When player is not very close and window is in view update it like every 10th frame
Get fast updates only on window when its in view and player is close.
And i think most of those above conditions could be done by automatic optimizations.

You could for eg create window mesh, LOD it, and apply different material to each lod.

But if I actually want the player to see what’s going on outside, like on the bridge, I would need relatively large windows. And 1k or 2k target renders are already causing lags.

And how do I make it so that it is updated individually on different clients? For example, one player is looking at a window another player is looking at a different window. On one player’s client only one render target should be updated but on the other player’s client only the other one should get updated.

Hello,

I reply to the thread one years later but i’m interested by the way you choose to solve your issue of “ship moving with players inside” like Star Citizen multi crew gameplay.
Did you use “static ship with everythings else moving around” method? Or something more tricky?

Thx.

Any update on this? I’m also quite interested as I’m trying to do the same in my own little project.

I don’t have to contend with extreme speeds, as the vessels I’m working with move at very low speeds 20 - 30 knots (max) but when you throw multiplayer in the mix character movement replication produces some horrendous rubber-banding when walking inside the ship. That was back in 4.7 and I’ve since moved to new solution where the Internal and External views are separately located. I’ve also been following Star Citizen’s progress with their “nested physics grids” but have no idea how to even begin with this in UE4.

Is there a way to attach a Character(Pawn) to another pawn and still have the character move about freely(walking, jumping, swimming, etc.)?

I noticed my turret movement was replicating smoothly even when another player was steering the ship so figured this might be a viable path to getting characters moving on board without the rubber-banding.

But the Turret only has to deal with rotation though, right?
Whereas pawns probably need custom movement code…
Overall this is tricky, that’s why RT usually works out best.

Otherwise you must override character physics system.
So that Pawns can be effectively ‘attached to ships’ etc.
Moving / jumping is artificial / no impact off ship velocity!

I’m making a game that allows you to walk inside a space ship, consisting of 8 decks, and will use simple panning to simulate outside movement in space from its windows since the ground simulators will be on the planets., I could make it also a space sim but
don’t know how to create the nebulas yet for the ship to fly though. i’m not sure where to start on this either in Unreal Engine 4
with blueprints because ofthe lack of geometry tools and resources and the limits the blueprints has…I can only do Basic shapes with these tools. And I need to know how to build the decks of the ship. But If I use Third Person Character for building all my 3d worlds then I will get the 3d world look, but I may have the issue of the game using up too many 3d resources for building the whole world.

As for the question there’s two options I can think of. That you can use a tile map system to cut down all the drag if you don’t have a powerful enough machine or enough ram, or do it as a 3d world using modular sets to build the ship interiors.

I don’t like the fact that there’s no auto rigger yet in Unreal Engine to save time in rigging all the models.

I remember keeping experimenting with this for a while but eventually giving up. I tried several things, like the players not actually being pawns but simply actors attached to the ship and making everything only 1/10th of it’s real size and things like that. But every solution brought new problems with it. I also had some weird issues with the graphics becoming very blurry while moving within the ship, which I still don’t understand. I’m still interested in this but I decided to switch to projects that seem more doable as one-man hobby projects for now.