# Best concept of Modular Space Ship that is assembled in runtime by player?

**URL:** <https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [August 24, 2023, 9:53pm UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489 "2023-08-24T21:53:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tonakien](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tonakien](https://forums.unrealengine.com/u/Tonakien)\
**Post date:** [August 24, 2023, 9:53pm UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/1 "2023-08-24T21:53:48Z")

</div>

Greetings! I wonder what is the best way to implement Modular Space Ship concept in Space Engineers style.  
That means that player will have ingame editor where he will select and snap ship blocks to the ship itself and then player will have ability to test his ship on playground flying around e.t.c.

My first noob idea is to snap blocks of a ship to each other as an actors through sockets. I thought in that way because Blocks have their unique functionality, parameters, animations and so on. Like subtype and parameters of thrusters/generators/armor/turrets will be unique to each block on the ship.

But I doubt that “this is the way” 🙂

Any Ideas?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [August 25, 2023, 7:26am UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/2 "2023-08-25T07:26:23Z")

</div>

> [@Tonakien](#):
>
> My first noob idea is to snap blocks of a ship to each other as an actors through sockets.

You may be able to get away with:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/7/f/e7f5e5798421cd9060e4e83e86a1ced6caae7d1f.png)

You get an inherited SMC, but also a full graph, variables, sockets, functions and so on. And all that without the overhead of a full-blown actor; and, most importantly, you can avoid pigeonholing yourself into relying on Child Actors.

Probably irrelevant if you have 10-20 pieces. May become relevant if you need 200 pieces in 20 ships. Look into inheritance if you’re not familiar with the concept, components support it; and exposing variables, too, thanks to this pretty node (`Add Component by Class` added in 4.26 or 4.27):

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/8/0a89f980d859b37cb1482b8319ec98fa1b8b3c1a.png)

* * *

I’ve build modular mechanical entities with this. It also works with skeletal mesh components. The only (can be major) drawback is that components cannot own other components - but that’s what socket attachment is for. Whether it is a drawback depends on how you organise and build stuff.

---

<div class="post-metadata">

**Author:** ![Tonakien](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tonakien](https://forums.unrealengine.com/u/Tonakien)\
**Post date:** [August 25, 2023, 7:33am UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/3 "2023-08-25T07:33:31Z")

</div>

> [@Everynone](#):
>
> nts supp

Thnx for the Idea with only Static Meshes!

Question with that implementation - can static meshes own animations/FX’s e.t.c.?

I want to pre assemble block in it full capacity in ue5 editor and then give it to player to attach to their ships.  
For example that means that thruster block will be applying force to whole construct, will have sounds, FXes and so on.

I doubt this possible (complete pre assembly in full capacity) by your method… or am I wrong?

PS  
One more point of input - Ship will be destroyable block-by-block just like in Space Engineers.  
This means that ship cut in half will create two “ships” with their corresponding blocks.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [August 25, 2023, 7:50am UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/4 "2023-08-25T07:50:42Z")

</div>

> [@Tonakien](#):
>
> will have sounds, FXes and so on.

It’s just variables referencing assets, so yes. You get a full graph to handle it. Or have the comps pull what they need from `Data Tables`. While the components cannot _own_ other components, they can spawn them.

> I want to pre-assemble block in it full capacity in ue5 editor and then give it to player to attach to their ships.

You can use an actor as a pre-assemble block base and then attach custom SMC (as in the original post) to said block. This will work well, both in the editor and with a fully dynamic setup in case the player wanted to detach a piece or blow it up or cut it off. The advantage here is that each extended SMC can have its own internal logic.

- this could be a manually pre-assembled block actor:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/2/a/02a7b60cd88c35beb565da157129f93b93f6d8a2.jpeg)

The engine SMC can apply force (at location) thrust to the root of the actor (or to something else). Were you to attempt doing the above with `Actors`, you’d need to rely on `Child Actor Components`.

> This means that ship cut in half will create two “ships” with their corresponding blocks.

This will take some (space) engineering, heh. But is doable. Look into procedural mesh slicing.

* * *

> in case the player wanted to detach a piece or blow it up or cut it off.

One note about component destruction that catches people off guard:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/c/2/fc2341fd85e17ce4db14540a26d1871fab09bc42.png)

You cannot destroy components as you please. You must politely ask the owner to do so for you or ask the component itself to _self_ destruct. It’s safer like this anyway.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [August 25, 2023, 7:56am UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/5 "2023-08-25T07:56:18Z")

</div>

@Nawrot You’re into spaceships. Have you done something like this before? Any insights?

We might as well try to summon @Tefel - perhaps we’re lucky. They’re on a glorious modular adventure, although not sure how much physical simulation there is:

> **[Tefel - Astro Colony](https://www.youtube.com/channel/UCK2gaQagPokKSyYGf2pqUEA)**
>
> Hey, I am a professional Unreal Engine 5 developer with 10 years experience in game industry!
> Making UE4 and UE5 tutorials. Check my free resources and plugins! Follow @TefelDev for more!
> Currently developing Astro Colony - endless voxel space...

Somehow I feel their input could be invaluable.

* * *

> Best concept of Modular Space Ship that is assembled in runtime by player?

The best concept is to get a second opinion 😇

---

<div class="post-metadata">

**Author:** ![Tonakien](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tonakien](https://forums.unrealengine.com/u/Tonakien)\
**Post date:** [August 25, 2023, 8:07am UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/6 "2023-08-25T08:07:20Z")

</div>

Thnx for your answers! 🙂  
I will wait for opinion of others but you convince me that I need to use one actor and bunch of SMC as blocks with their logic and everything else 🙂

PS  
BTW I will not slice blocks on destruction. I mean if block destroyed, it is destroyed completely. Ship will contain hundreds of blocks.  
Only one thing to engineer in that regard - the way to identify: was this clump of blocks cutted entirely from another clump of blocks?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [August 25, 2023, 8:15am UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/7 "2023-08-25T08:15:47Z")

</div>

> [@Tonakien](#):
>
> Only one thing to engineer in that regard - the way to identify: was this clump of blocks cutted entirely from another clump of blocks?

How is the slicing going to work? What is supposed to happen if I laser this like so while core #4 is attached to some other block?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/e/1/fe12f32ce1eaf9193d2de67fb0590fdc51403390.jpeg)

How about now:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/0/7/007c9d4881bee06c97e72b788e5f8fd948122740.jpeg)

Will 1 & 2 survive this? if so, what happens to them? What happens to the 3,4,5? Or the individual components do not matter?

---

<div class="post-metadata">

**Author:** ![Tonakien](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tonakien](https://forums.unrealengine.com/u/Tonakien)\
**Post date:** [August 25, 2023, 8:47am UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/8 "2023-08-25T08:47:54Z")

</div>

On first picture I didnt understand what block is hitted by the laser. Is it 1 then 2 (horizontal ray) or just 2 (vertical ray)

One second picture I assume that laser hit block 5 and then block 4 (vertical top-down hit).  
Assuming blocks 1, 2 and 3 was attached to block 4 by my logic happens next: Block 5 and 4 are destroyed (destroy component), blocks 1,2,3 are detached and becoming their own “ships” (in free flight) with impulse given from explosion of blocks 5 and 4.  
But as I sad, I need to identify that block (or group of blocks) need to become their own ship by checking are they “physically” connected to each other body-to-body way.  
I assume that will require creating a map of connected blocks and function to check connectivity if block dies.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [August 25, 2023, 9:07am UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/9 "2023-08-25T09:07:29Z")

</div>

> [@Tonakien](#):
>
> On first picture I didnt understand what block is hitted by the laser. Is it 1 then 2 (horizontal ray) or just 2 (vertical ray)

I mean a slicing _plane_. A ray would just puncture. Think of the ray as of a moving slicing beam that would chop some of it off:

As in:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/1/b/91b11af80f0e328ac0c229575035f3a3c1bc5586.jpeg "How to Salami Slice Mesh In Unreal Engine - Easy") ](https://www.youtube.com/watch?v=oIdKxYYQBdw)

> I assume that will require creating a map of connected blocks and function to check connectivity if block dies.

That could be one way of doing things, for sure.

---

<div class="post-metadata">

**Author:** ![Tonakien](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tonakien](https://forums.unrealengine.com/u/Tonakien)\
**Post date:** [August 25, 2023, 9:12am UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/10 "2023-08-25T09:12:28Z")

</div>

Ah. No, nothing like that. Just total block removal.

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [August 25, 2023, 12:00pm UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/11 "2023-08-25T12:00:39Z")

</div>

Yes i am into space and ships. And that socket idea works wonderfully in “Galactic Civ 2”.  
Currently I am doing some simple space game, and thinking about doing modular ships.

GalCiv 2 editor:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/a/f/4afd2159675ece4953988ec64dd5c710a1b697f5.jpeg "Gal Civ 3 Ship Designer") ](https://www.youtube.com/watch?v=kWG-ekchhNA)

It works great for visual of ships, however if you want something for game-play like Space Engineers style It would require something better.

Gal Civ editor snapping works like tree structure, so probably you need to code that. Then add sockets (better in data struct than in meshes). Also there is problem of draw calls (this is why i am unsure my game needs ship editor). Each module will be separate piece.

Great package from marketplace:

> **[Amazing Sci-Fi Modular Drones and Spaceships in Props - UE Marketplace](https://www.unrealengine.com/marketplace/en-US/product/amazing-sci-fi-modular-drones-and-spaceships)**
>
> Meshes for construction of Sci-Fi drones, carriers, spaceships, structures. Bonus Functionality Blueprints.

---

<div class="post-metadata">

**Author:** ![Tonakien](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tonakien](https://forums.unrealengine.com/u/Tonakien)\
**Post date:** [August 25, 2023, 1:06pm UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/12 "2023-08-25T13:06:39Z")

</div>

> [@Nawrot](#):
>
> Each module will be separate piece.

You mean separate actor? I mean i will work for “modules”, but I doubt it will work for “blocks” like in Space Engineers.

In my mind whole ship is a set of relatively small blocks. And there will be a lot of those blocks in one ship. Almost exactly as in Space Engineers.

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [August 25, 2023, 1:44pm UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/13 "2023-08-25T13:44:27Z")

</div>

Piece, as component.

This is why you need that tree structure, that remembers which mesh is “parent” and which is connected to it and which socket, and transform (relative location, rotation and scale). So you can build whole space ship out of that tree data.

Code would be quite “simple”

- tree structure that remembers hierarchy
- some struct that describes all sockets
- another struct that holds mesh, which socket it is connected to , and its transform

That is simple, but making editor in game for this, is much harder.

ps.  
Ahh you want it more like space engineers, then best would be some grid and locations on that grid.

---

<div class="post-metadata">

**Author:** ![Tonakien](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tonakien](https://forums.unrealengine.com/u/Tonakien)\
**Post date:** [August 25, 2023, 1:56pm UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/14 "2023-08-25T13:56:34Z")

</div>

> [@Nawrot](#):
>
> Ahh you want it more like space engineers, then best would be some grid and locations on that grid.

Thats where “almost” comes in 🙂  
Space Engineers ships is a grids. I want “Freeform building” which means there will be a lot of blocks but there will be no hard grid. Blocks will connect to other blocks via sockets but those sockets will not be strict oriented (not like in grids)

And you are absolutely right - I need “Block connection map”. But structure will not be hierarchical because one block can be connected to many, so it is not “who parent to who” but rather “who connected with who”

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [August 25, 2023, 2:04pm UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/15 "2023-08-25T14:04:31Z")

</div>

Look into “Wave function collapse”  
like this one:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/1/8/118f6cb230c30d285b392a7888f6e2e42b0b51dd.jpeg "Superpositions, Sudoku, the Wave Function Collapse algorithm.") ](https://www.youtube.com/watch?v=2SuvO4Gi7uY&t=468s)

Make “shapes” of meshes, create ship out of them. Instead of random generation , let player choose variants.

---

<div class="post-metadata">

**Author:** ![Tonakien](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tonakien](https://forums.unrealengine.com/u/Tonakien)\
**Post date:** [August 25, 2023, 2:57pm UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/16 "2023-08-25T14:57:32Z")

</div>

Thnx for the video but that is above my mental capabilities 🤣

---

<div class="post-metadata">

**Author:** ![Nawrot](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nawrot/32/618260_2.png) [@Nawrot](https://forums.unrealengine.com/u/Nawrot)\
**Post date:** [August 25, 2023, 3:30pm UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/17 "2023-08-25T15:30:36Z")

</div>

Then do not with such project, it will require some code like that.

Then you will have load order troubles, like when you need to reference actor that is not loaded yet, which is impossible, so you need rebuild whole logic of game, etc.

Start simpler project, like “galciv 2” snap to socket ship constructor.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [August 25, 2023, 4:29pm UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/18 "2023-08-25T16:29:46Z")

</div>

> I need “Block connection map”. But structure will not be hierarchical because one block can be connected to many, so it is not “who parent to who” but rather “who connected with who”

While you cannot dynamically create sockets in BPs, you can give meshes sockets manually and grant them unique tags:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/0/a/10a21275a4c8bee8b4bdfedece726e61a3c66c0f.jpeg)

Your component can keep track of other attached components either by using socket names or the abovementioned tags which could provide extra flexibility:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/5/4/8546ac782d0c85f08a4bf836ae7f2462079ca017.png)

This is just _pseudoscript_, ofc.

* * *

In my case, I had a specialised smart connector that performed that function - I needed to have an entity that would move data between components even though they were _not_ attached. So it was a tad more complex. Think _wireless cables_.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/9/1/691950ff659867e6b1c517c4603226ab3a833b0b.jpeg)

* * *

Another way of keeping track of what is attached without mapping it, is to trace. You trace to each of the sides (or through every socket) and see what else is there. You’d need to create rules regarding what is considered _attached_ - proximity / compatibility etc.

---

<div class="post-metadata">

**Author:** ![Tonakien](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tonakien](https://forums.unrealengine.com/u/Tonakien)\
**Post date:** [August 25, 2023, 5:47pm UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/19 "2023-08-25T17:47:03Z")

</div>

> [@Everynone](#):
>
> While you cannot dynamically create sockets in BPs, you can give meshes sockets manually and grant them unique tags:

Yes. Sockets you showed is exactly my line of thoughts.  
I already implemented socket spawn and connection.

BTW question about Sockets - I was forced to create custom function to attach child component not by its pivot but by its corresponded socket coordinates.  
Is there a way to do that without custom functions?

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [September 24, 2023, 5:47pm UTC](https://forums.unrealengine.com/t/best-concept-of-modular-space-ship-that-is-assembled-in-runtime-by-player/1271489/20 "2023-09-24T17:47:49Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
