Training Stream - Procedural Room Generation - Jan. 6th, 2015

Heya n00854180t,

To the scale: I think I may have hard coded some math in the digger that assumes 100 unit tiles; look for anything that * or / against 100, or a Tile Size like variable that may not be getting its value set from outside (set those to 500 by default). Also the controller has some serious assumptions in it. I’ll have a moment to look at everything mentioned in thread post GDC2015, and then update the download =)

To the 2nd bit, to really get it functioning as an Actor in the Level Editor, you’ll need to combine at least 5 Actors: Quadtree, GridData, AABB, the wall collision, and the floor collision; and work all of their functionality into a Construction script. The problem is that construction scripts don’t allow for spawning of Actors. So you’d have to do things like store a number of box components that represent the AABB Actors, then include any functions needed from those Blueprints, and re-work calls, etc… The fact things are disappearing after you use your Bluetility and use Play seems like a bug, because all of that data should stick into Play (longer version: the construction script isn’t run again during Play in Editor/Simulate, the Actors are simply copied to the Play in Editor/Simulate world, so the state from the level editor should persist into play).

It’s totally doable. In fact, with the new scriptable components in 4.7, I think would be even easier to do. It could become a series of functions that could be called from either the game to generate a new map or from the construction script… I’ll have to look into that.

Actually, I need to just sit down and update it to the latest and greatest in everything. As it stands now, it’s setup in a number of ways due to the evolution of the Engine while I was working on it. There are old workarounds for things like Blueprint corruption, link breaking, lack of direct Blueprint Communications, Instanced Static Mesh components that drop collision, etc… that are totally unnecessary now.

Ah! That would explain things. I ended up just using the method where I scale the FloorMesh InstancedMeshComponent up uniformly by 5 (for a 500 unit tileset) with my tiles scaled down to match the default ones. I set up the collision boxes to be bigger and show up in the right place as well (just made copies and replaced the refs to them).

What I ended up doing was creating a custom event in WorldData and ticking the Call In Editor box. Then I moved the code from TBS_Game to the event, and passed WorldData into the setup calls for the Quad Tree and Grid Data (and stored that in those for later, whenever the random stream is used).

worked flawlessly right away if the event was called (via selecting the WorldData instance and going to the Blutility drop down) while the game was running, but was failing mysteriously if ran while in the editor.

I tracked down to some odd behavior where parameters passed through the Spawn node seemingly don’t ever get set if called from a Call In Editor event, and ended up making initialization functions that just re-set those variables. I still had an where the AABBs were not being set up right (their extents and such weren’t being set in the constructor, same deal) and finally got that working.

Oddly, the workaround with the set of transforms doesn’t work unless the transforms are set to be editable/public.

In any case, it all works now such that you can click WorldData, click CreateLevel -> Run in the Blutility section, and it will spit out a level (assuming the settings are set). I even have a vector offset for spitting out one level on top of another easily (though you can just move them and then refresh instances).

There’s another Blutility function on GridData for refreshing the instance lists (from the saved transforms), which is useful if you have to move the Grid Data at all because that, too, disappears all the instances from their lists. Clicking the refresh will get it back though.


The only remaining thing I’d like to be able to do is make it so that when the level and all the actors are created, everything is parented under the Grid Data in the scene hierarchy (e.g., all the collision actors and such). As makes it much easier to move (in conjunction with the refresher function).

Edit: Didn’t realize that “Attach” would do what I want here in the Scene Outliner. So that works now too!

Hey. How would I go about disabling the turn-based strategy part of project and have it use my own character and controller instead? I’ve tried digging around the various blueprints but I just can’t figure it out.

Hey Mindtrucks,
It really depends on what you’re looking at doing, but, primarily, you’d want to modify the following Events in the MainPlayerController:

  • TileClicked
  • Getting Nav
  • UnitClicked

And on Unit

  • Move Unit

Or create your own Unit Blueprint Class (as the ones I made were Pawns and not Characters, so they have no movement component if you wanted to use the NavMesh)

Speaking of NavMesh, you’d have to generate a NavMesh Volume around the play area, and set your project NavMesh setting to rebuild at runtime. You could then get rid of the A* nav Blueprint.

OR if you really just want to have the world generated and spawn your own things, only keep the top bit of the MainPlayerController (Tick, WASD, Zoom, Begin Play). will leave you with just the light moving around the cursor, and movement controls. Then in the TBS_Game Blueprint, you can break the execution connection from GridComplete Event to the Set Rooms node. will stop the Unit Manager and A* Actor from spawning, leaving you free to insert what you want there to handle unit creation.

If you have any specific ideas of what you’d like to do, I can also get more specific on what you’d want to cull/re-purpose.

Hey , thanks for the reply. I broke a bunch of the connections you mentioned and managed to spawn my own third person style character in, which is great! But now my fired projectiles are sometimes colliding in mid-air. I tried disabling all the collision spawners in GridData and even changed the collision on the instanced mesh components too, but nothing seems to do the trick. Got any ideas?

Mindtrucks, the mid air collision could be the player pawn as it has collision, but mostly disabled… Are the colliding with each other? Perhaps you could toss up a vid/gif of what’s going on =)


! So a change was made in 4.7 to variables and how you can access them. If a variable is not Editable, you won’t be able to access using Blueprint Comms. I leverage BP Comms almost everywhere, and while map generation isn’t affected, Units will be if you ever compile the Unit Blueprint. The symptoms will be: Selected Units have no health, power, or movement bars, and Selected Units cannot move. The fix is simple, just make all the variables on Unit “Editable”.

Nice presentation, but it’s too advanced for some of us, I think a full Video Series with step by step info will be a great tutorial . For us that are not that advanced into Blueprints .

Hey,
I was looking for a Turn Based Strategy template and of course I found , but sadly the part that is most important for me isn’t working: the turn based strategy stuff. When I just create a project with the template and run it, I get a perfectly fine level and all the characters, but when I select a character, I can only turn him around and not move him.

Heya GigaGrunch,

The fix is bit from above:

One of these days I’ll get the time to update the project so doesn’t happen…

Thanks man! I really thought I didn’t miss anything when speed-reading the thread.

Hello and sorry to bother people for what im sure is a very stupid and quick answer, but i was working on trying to follow the video and got some odd errors. Hopefully someone can help me figure it out from the screenshots. I just made two quick floor meshes in Blender to try and follow the video, i figured out how to force it to export to a certain dimension (100,100,5) and double checked its size after import into UE4, so they both are those dimensions and should work if i understand how your using yours in the video, but i have a sneaking suspicion something is wrong with them anyway and thats whats causing the. Here are the screens:

https://goo.gl/photos/53njoC3mb33XaDDs7

https://goo.gl/photos/qozUVJgdr9Udt9uY7

https://goo.gl/photos/Er7hnW3jHj5ZSfAZ7

https://goo.gl/photos/Aj4UTrf2JNjFjbTx6

Nice video, but. I hear what : “I can generate level on the ‘construction script’”
But I can’t. ( because SpawnActor not works in CS )
How I can improve example.
Thx

Any we could have a redo on the twitch stream? But more of an intermediate level than super advanced, for those of us that already know the basics and are comfortable but are not super programmer types? Should be going through each function, BPs, etc, explaining the why and hows. If not a twitch, then maybe a fully 100% documentation low-level tutorial? Thanks!

Is still available? I really want it :slight_smile:

yes, look for “Turn Based Strategy”

Where can one download the project now?

@DemonWork - like stated above and on Original Post: it’s under the Learn Tab about 3/4 of the way down - and it’s named Turn Based Strategy

also watch the original Twitch Learning Broadcast here: https://www.youtube.com/watch?v=mI7eYXMJ5eI&list=UUBobmJyzsJ6Ll7UbfhI4iwQ

gl :wink: