Dungeon Architect

@TechLord You’ll need to first determine how you’ll need to emit the markers on your skeletal mesh. One way to do it is to sample the points in the skeletal mesh’s geometry and then filter them based on how you’d like to lay them out. and example I worked on a while ago with static meshes (the red dots are the sample points that can be used as markers)

https://.youtube.com/watch?v=JGielIkvEYE


bool SampleTriangle(const FVector& v0, const FVector& v1, const FVector& v2, const FVector& Offset, float Density, TArray<FGrowthNetworkSamplePoint>& OutSamples) {
    int32 RandomSeed = GetTypeHash(v0) ^ GetTypeHash(v1) ^ GetTypeHash(v2);
    FRandomStream Random;
    Random.Initialize(RandomSeed);

    float TriangleArea = 0;
    float DesiredInstances = 0;
    float DensityMultiplier = 5000000;
    {
        FVector AB = v1 - v0;
        FVector AC = v2 - v0;
        TriangleArea = FVector::CrossProduct(AB, AC).Size() / 2.0f;
        TriangleArea = FMath::Max(TriangleArea, 1.0f);
        DesiredInstances = FMath::RoundToInt(TriangleArea * (Density / DensityMultiplier));
    }

    bool bStateModified = DesiredInstances > 0;
    while (DesiredInstances > 0) {
        FVector Location;
        GetRandomPointOnTriangle(v0, v1, v2, Random, Location);

        FGrowthNetworkSamplePoint Sample;
        Sample.Location = Location + Offset;
        OutSamples.Add(Sample);
        DesiredInstances--;
    }
    return bStateModified;
}

bool SampleStaticMeshPoints(AStaticMeshActor* MeshActor, float NormalOffset, float Density, TArray<FGrowthNetworkSamplePoint>& OutSamples) {
    bool bStateModified = false;

    UStaticMeshComponent* StaticMeshComponent = MeshActor->GetStaticMeshComponent();
    if (!StaticMeshComponent) return bStateModified;

    UStaticMesh* StaticMesh = StaticMeshComponent->GetStaticMesh();
    if (!StaticMesh || !StaticMesh->RenderData) return bStateModified;
    if (StaticMesh->RenderData->LODResources.Num() == 0) return bStateModified;

    TArray<FVector> Vertices;
    const FStaticMeshVertexBuffer& VertexBuffer = StaticMesh->RenderData->LODResources[0].VertexBuffer;
    const FPositionVertexBuffer& PositionVertexBuffer = StaticMesh->RenderData->LODResources[0].PositionVertexBuffer;
    FVector MeshLocation = MeshActor->GetActorLocation();
    FTransform MeshTransform = MeshActor->GetActorTransform();
    const int32 VertexCount = PositionVertexBuffer.GetNumVertices();
    for (int32 i = 0; i < VertexCount; i++)
    {
        const FVector WorldSpaceVertexLocation = MeshLocation + MeshTransform.TransformVector(PositionVertexBuffer.VertexPosition(i));
        //const FVector WorldNormal = MeshTransform.TransformVector(VertexBuffer.VertexTangentZ(i));
        Vertices.Add(WorldSpaceVertexLocation);
    }

    const FRawStaticIndexBuffer& IndexBuffer = StaticMesh->RenderData->LODResources[0].IndexBuffer;
    TArray<uint32> Indices;
    IndexBuffer.GetCopy(Indices);
    int NumIndices = IndexBuffer.GetNumIndices();
    for (int i = 0; i < NumIndices; i += 3) {
        uint32 i0 = Indices*;
        uint32 i1 = Indices*;
        uint32 i2 = Indices*;

        const FVector& v0 = Vertices[i0];
        const FVector& v1 = Vertices[i1];
        const FVector& v2 = Vertices[i2];

        FVector Normal = FVector::CrossProduct(v1 - v0, v2 - v0);
        Normal.Normalize();
        FVector Offset = Normal * NormalOffset;

        bStateModified |= SampleTriangle(v0, v1, v2, Offset, Density, OutSamples);
    }

    return bStateModified;
}


Finally, when adding the component, you’ll need to find the nearest socket, calculate the offset, then attach to it


@intoxicat3 for Start / End rooms, have a look at the sample maps under DA_Query_Examples/Grid folder in the quick start examples

The door should be the same size as the grid, larger doors are not supported

That exactly!

Can be cool if work like that with rooms but aswell dungeon style with rooms and connections etc…

[USER=“28980”][/USER] Are you still going to post a tutorial how to create a larger City Scene in DA? I cannot figure out how to add the Larger buildings and create a City Block. I been trying to figure out how to make this happen. Any help would be appreciated.

[USER=“28980”][/USER]

I appreciate you taking time to respond. The Procedural Growth Network looks really neat (and kind of creepy). Working with Procedural Meshes is definitely on my to list. I’m a blueprints scripter so ill have to figure out how to translate the C++ into a blueprints equivalent.

Any you can add support for it? Eg. Door size could be more than grid size.

I have a problem with dungeon selector logic. I would like to do traces to determine the space between the dungeon and landscape however because the selector BP is not an actor child the trace functions are not available.

Does anyone know how i can make the trace functions available in the selector BP?

Hi.

I currently use SnapBuilder level generation (as I have much more control over the rooms compared to gridbuilder - and I need this for a topdown view game).

The level generation with the Blueprint version of SnapDungeonBuilder works ok and is fast, but I wonder if this is further in developement.
The SnapBuilder version stitching rooms defined as levels does not work, is VERY slow and crashes unreal editor way too often!

So will the blueprint version SnapDungeonBuilder be developed any further? I really need options for limiting rotation of rooms that I read about a year or so…
Setting Side Branches > 0 does not work at all … the rooms overlap all the time.
And the SnapConnectors show the little red arrow not at the origin of the actor - I don’t know why.

Maybe you have time to respond to my questions.

Thanks,
Lars

I would love something like that in this, yes!

I pored through the engine code tried a few different approaches for the snap builder crash issues but I still seem to be doing something wrong :expressionless: It crashes due to a invalid memory reference while the engine tries to tick the level’s callback function.

I’ll continue working on this and update tomorrow on the status

Hi all, I’m trying to make a custom selector that detects if a wall has a halfwall under it, any ideas on how this could be accomplished?

As I said … the version using Blueprint as their “rooms” is working OK for me - no crashes and fast generation (compared to the level stiching version WAY faster).
And the problem designing those Blueprint can be perfectly solved by using the Prefab addon from the Marketplace. You actually design the Blueprints in the level editor of Unreal - works good.

But the DA side need some bugfixing and a little more features (as I described above).

What’s also needed is the ability to suppress some actor types from the Blueprints (if this is possible) and the ability to restrict some “rooms” to occur only once (or a definable amount) - no one want’s 2 boss rooms of the same type in one level :wink:
And rooms occurring in an exact order would be nice for gameplay, too.

Thanks for working on it,
Lars

Sorry for reviving this old response, first of all thank you very much to Konflict for his response, it completely fixed my reported bug.@, did you found something wrong with this fixes? I’m asking because I plan to use this feature and it’s not very usefull in it’s broken state. I’d love it if this fix made it into the code so we don’t have to keep track of fixes we make and merge every time a new update gets released.

I’m also using the Blueprint version of Snap dungeon to great effect! Works really well for my game that needs some crazy types of room placement (very vertical gameplay that normal dungeons can’t build.)

Lars - which Prefab addon are you talking about? Sounds helpful!

I concur with some features that would take Snap dungeon to the next level:

  • a way to weight or limit rooms to avoid too many of the same (Lars, how I’m doing it is a Boss room would only be an End room in a level, so you’d only have one, or you build a level chunk that can turn itself into a non-boss room if one had already been spawned
  • a way to prevent the same room from attaching multiple times in a row (sometimes I get the same room 3-4 times in a row and want to avoid that)

For my game, those two things and a general stability pass and I think SnapDungeon would be shippable! I wrote my own method of using HISMs with SnapDungeon and it works pretty well, but I guess HISM support would also help :smiley:

https://.unrealengine.com/ja/marketplace/prefab-tool

This plugin can be used very well to create and update the Blueprints …

Just tried to add this to my new project and I get a crash instantly on the editor. The crash is related to some deep engine code with UI updates to the editor. It does not happen on a fresh new project, however we are using “gameAbilities” from the paragaon and fortnite system. Possible conflict there?

Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:D:\Build++UE4+Release-4.18+Compile\Sync\Engine\Source\Runtime\Core\Public\Containers/Array.h] [Line: 610] Array index out of bounds: 3 from an array of size 1

UE4Editor_Core!FDebug::AssertFailed() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:414]
UE4Editor_LevelEditor!SLevelEditor::RefreshEditorModeCommands() [d:\build++ue4+release-4.18+compile\sync\engine\source\editor\leveleditor\private\sleveleditor.cpp:1334]
UE4Editor_LevelEditor!SLevelEditor::RestoreContentArea() [d:\build++ue4+release-4.18+compile\sync\engine\source\editor\leveleditor\private\sleveleditor.cpp:1134]
UE4Editor_LevelEditor!SLevelEditor::Initialize() [d:\build++ue4+release-4.18+compile\sync\engine\source\editor\leveleditor\private\sleveleditor.cpp:176]
UE4Editor_LevelEditor!FLevelEditorModule::SpawnLevelEditor() [d:\build++ue4+release-4.18+compile\sync\engine\source\editor\leveleditor\private\leveleditor.cpp:168]
UE4Editor_LevelEditor!TMemberFunctionCaller<FLevelEditorModule,TSharedRef<SDockTab,0> (__cdecl FLevelEditorModule::)(FSpawnTabArgs const & __ptr64) __ptr64>::operator()<FSpawnTabArgs const & __ptr64>() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\core\public\delegates\delegateinstanceinterface.h:165]
UE4Editor_LevelEditor!UE4Tuple_Private::TTupleImpl<TIntegerSequence<unsigned int> >::ApplyAfter<TMemberFunctionCaller<FLevelEditorModule,TSharedRef<SDockTab,0> (__cdecl FLevelEditorModule::
)(FSpawnTabArgs const & __ptr64) __ptr64>,FSpawnTabArgs const & __pt() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\core\public emplates uple.h:497]
UE4Editor_LevelEditor!TBaseRawMethodDelegateInstance<0,FLevelEditorModule,TSharedRef<SDockTab,0> __cdecl(FSpawnTabArgs const & __ptr64)>::Execute() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:556]
UE4Editor_Slate!TBaseDelegate<TSharedRef<SDockTab,0>,FSpawnTabArgs const & __ptr64>::Execute() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:537]
UE4Editor_Slate!FTabManager::SpawnTab() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\slate\private\framework\docking abmanager.cpp:1414]
UE4Editor_Slate!FTabManager::RestoreArea_Helper() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\slate\private\framework\docking abmanager.cpp:1273]
UE4Editor_Slate!FTabManager::RestoreSplitterContent() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\slate\private\framework\docking abmanager.cpp:1388]
UE4Editor_Slate!FTabManager::RestoreArea_Helper() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\slate\private\framework\docking abmanager.cpp:1357]
UE4Editor_Slate!FTabManager::RestoreArea() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\slate\private\framework\docking abmanager.cpp:1249]
UE4Editor_Slate!FTabManager::RestoreFrom() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\slate\private\framework\docking abmanager.cpp:808]
UE4Editor_MainFrame!FMainFrameModule::CreateDefaultMainFrame() [d:\build++ue4+release-4.18+compile\sync\engine\source\editor\mainframe\private\mainframemodule.cpp:206]
UE4Editor_UnrealEd!EditorInit() [d:\build++ue4+release-4.18+compile\sync\engine\source\editor\unrealed\private\unrealedglobals.cpp:124]
UE4Editor!GuardedMain() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\launch\private\launch.cpp:150]
UE4Editor!GuardedMainWrapper() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:134]
UE4Editor!WinMain() [d:\build++ue4+release-4.18+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:210]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253]

ntdll"

@Laurentius Lars, Thanks for the feedback. Earlier, I found designing in the blueprint editor to be a pain, but like you say, the Prefab tool seems to fix that. I’ll try to support both by abstracting the module source (blueprint or level module)

are some of the Pros and Cons of each one:

Blueprint Based Snap builder

  • Fast generation (in editor)
  • Fast generation (at runtime)
  • Stable (in editor)
  • Stable (at runtime)
  • No level streaming
  • No lightmapping
  • No BSP Brushes
  • No foliage (BP doesn’t support it)
  • No vertex painting (?)

Level map based Snap Builder
- Slow generation (in editor)

  • Fast generation (at runtime)
    - Unstable (in editor)
  • Stable (at runtime)
  • Level streaming
  • Lightmapping support
  • Folliage support
  • Vertex painting support
  • BSP Brushes

Going with the level based modules has a lot of advantages, once the stability and build performance issues are sorted out. (especially the level streaming and lightmap support for VR and mobile)

@Ratamorph @Konflict I’ll look into this

Sean, I’ll test it in High Sierra and let you know

Looks like a layout issue. Could you try restoring your editor’s layout and restart the editor? (Window > Reset Layout)