How do I make a spaceship where I can walk around in a ship while said ship is moving freely?

Hi, I am trying to make a game that has vehicles that have an interior. as in a player could walk around in a dropship before a match (the game is a third-person shooter/hack and slash) or around the interior of a battleship, while said ship is engaging hostile forces. what would I need to do that? attachActorToComponent does not work that well. any help is welcome

That is an interesting premise, and I too would like to check out the answers you are given here, though I haven’t got that far a long in UE4 myself to be testing multiplayer things to offer you enough of a solution to this problem. I suppose it is just a matter of getting the player inside the space you want them in and have some kind of collision for the floor and walls or else they pass right through right? And it wouldn’t be a possession I suppose as you would not be controlling said vehicle just existing inside it freely.

I think there are several possible ways this can be approched and all are fairly complicated.

The first possible solution is to move all characters around the actual ship, which is really complex and I wouldn’t do such an approach if it is not absolutely needed.

Another MUCH easier approach would be possible if you only have a specific amount of ships (like one or two). Than you could spawn specific streamed levels for your ships in a place of the actual map. In these ships you can walk around like normal and they aren’t moving at all.

In specific places (like windows and so on) you could place textures which show the view from different camera angles of the ship, which is flying through the open world.

This is imho a much much easier approach. Unfortunately you have to teleport your character into the streamed ship level when entering the ship itself.

I could imagine that this approach is much easier and also possible in multiplayer.

I cannot believe that it would be possible to move replicated actors in multiplayer around a flying replicated object without syncing issues and actors falling through other actors and so on (like in the first approach).

I’m with HAF-Blade… If you were working in C++ or in a custom engine, I could imagine solutions involving parenting objects to the moving ship and getting the game-physics and networking to play nice with parented objects.

However, working in UE4 blueprints, I think you will have the best time making a stationary ship model somewhere else on the level, which players are ā€œteleported toā€ when they get on the ship, and ā€œteleported offā€ when they leave the ship, and then doing rendering fakery to make it appear like this ship is actually somewhere in the world and moving. (a bit like how the game ā€œPortalā€ creates portals)

You would place a stationary copy of each ship instance somewhere not visible on your map. Anytime a player jumps near a ship, you teleport them to the ā€œhiddenā€ ship instance area.

When they are on the ship, you want them to see the world outside the windows. So when they are on the hidden-stationary-ship, you would render the world to a texture, which you will use as a ā€œbackdropā€ behind the ship. To make this look right, make a camera in the world that mirrors the location (and rotation) the player should be in the world. The location would be (playerPos - hiddenShipPos) + shipWorldLocation . Attach a plane to the hidden stationary ship, and rotate it to always be ā€œbehindā€ the ship (opposite the player camera direction), and render it in screen-space… then stick the world-backdrop-texture on it.

Of course, you would like people in the world to also see players on the ship. When a player is teleported to the stationary ship, you will need to make a proxy character that stays in the world and mirrors their position and rotation (much like their camera is doing)…

When an object (player, projectile, etc) crosses the magic bounding box onto the ship, it will be teleported to the ship and a visual proxy created in the real world… and when an object crosses a bounding-box around the stationary ship, its proxy will be deleted and it will be teleported back to the world.

I’m not sure how to get this teleportation to happen without any network related movement hitches. I would start by trying to make a teleport script (see magic teleportation) and then using an RPC to replicate it to the server (see howto replicate sprint)

Unreal Engine 4 Tutorial - Basic Camera Feed - YouTube

UE4 tutorial07-04: Materials, render to texture - YouTube

Unreal Engine 4 Magic Tutorial, Teleportation! (Request) - YouTube

How To Replicate Sprint - UE4 - YouTube

There are some artifacts when you simply attach the actor to the moving actor.
You need to dig into the movement system, improving some behaviors and making sure that physic calculations are accurate. In my case I had to rewrite movement component to make it right, in addition making sure that for very high velocities ā€œrebase world originā€ is also used.

after trying the portals with interior under the level approach it would appear that I will need to with the first possible solution. as many of the ships that will be created will mostly be open top. picture a sailboat as those are, for the most part, what I am working with. I would imagine a physics-based approach would be optimal. do you have any resources or ideas as to how that would work?

Those just work. Like moving platforms just work.

The issue with space vehicles is that in engine you’d get the same result if you went walking around a cargo plane while it’s performing a loop.

That’s obviously not an issue for anything that needs to maintain ā€œearthā€ like gravity to its interiors.

from what I have seen moving platforms do not ā€œjust workā€ as the moving platform does move but it does not take the player with it. what are you doing to achieve that result? as, for the gravity situation, the ideal solution is a potential toggle option that would allow the gravity to be changed on a dime. how I would go about doing that?

Nothing at all.
They just work with the character blueprint.
Nothing to it.

Replicated movement is a different story.

as so that is where I am going wrong I need replication.

Check if maybe the community ocean project has replication going for the boats.
I know they worked on it at one point or another.