Construction System

I know this has nothing to do with the RPG Course, and please ignore if you wish to do so, but I was just wondering if anyone ever attempted and successfully implemented a grid-based construction system for their game? (I’m trying to implement this ON A COPY OF THE MASTER RPG PROJECT REPO, as I wait for Brian to release a new chapter of his series). I recently purchased the ‘Easy Build System’ from the Unity Asset Store by PolarInt, and the developer takes a while to respond to my questions, so I’m seeking help here (even though I know this is not the right place to be, but something is better than nothing…)

If anyone purchased that system and managed to integrate it into their game, or knows how to integrate one, that would be amazing

For context, here is what he told me about trying to integrate his system into my game:

To start, in your inventory system, create a new "string" variable in your "item.cs" script or something similar.
// by 'item.cs', I assumed he meant my 'InventoryItem.cs' script, but that didn't work too well for me...
This variable should contain the same identifier as the Building Part that will be placed when you use the item in question.

Next, you need to create a new method that you'll call when using your item from the inventory to preview the Building Part.

Example: "TryUseBuildingItem(string identifier)". Add your identifier, which you added earlier, as an argument.

This method will allow you to preview the desired building without actually using the item.
For example, if the player cancels the placement with a right-click, it would be silly to use the item.

Now, here's where the integration happens:

When you call the method you previously created (TryUseBuildingItem), you can enter preview mode by calling these following methods:

// Here, we directly take the "identifier" argument we passed. This will allow us to reference the Building Part in question.
BuildingPart partReference = BuildingManager.Instance.GetBuildingPartByIdentifier(string identifier);

// Now that we have the reference, we select it in the Building Placer.

// Here, we switch into placement mode to preview the Building Part.
BuildingPlacer.Instance.ChangeBuildMode(BuildMode mode);

When this is done, you just need to use an event from the system to detect if a Building Part has been placed:

BuildingManager.Instance.OnPlacingBuildingPartEvent.AddListener((BuildingPart part) => { });

Of course, inside this event, you check that the placed Building Part's identifier is the same as the one used by your item.
Then, you can delete the item or decrease the amount by 1, depending on the item type.

I hope this isn't too confusing. This is the approach I used for integrating the system with RPGBuilder, so if you have the asset, you can take a look at it; it will make things easier for you.

and here is what I attempted to code, following his instructions (in my ‘InventorySlotUI.cs’ script). I’m not sure why I chose “InventorySlotUI.cs” instead of “InventoryItem.cs”:

// EASY Build System Integration:
        public string buildingPartIdentifier;

        public void TryUseBuildingItem(string identifier)
            // Retrieve the BuildingPart reference based on the identifier:
            BuildingPart partReference = BuildingManager.Instance.GetBuildingPartByIdentifier(identifier);

            // Check if the reference is valid:
            if (partReference != null)
                // Select the building part in the Building Placer:
                // Switch to placement mode, for previewing the Building Part:

        void Start()
            BuildingManager.Instance.OnPlacingBuildingPartEvent.AddListener((BuildingPart part) =>
                if (part.GetGeneralSettings.Identifier == buildingPartIdentifier)
                    if (item.IsStackable())
                        Inventory inventory = Inventory.GetPlayerInventory();
                        RemoveItems(1); // kinda clueless of how to get a count on that

Any help or leads on this would be appreciated (but please keep the language simple), I’m willing to try program it on my own, or even try code my own from scratch, but I’m struggling to get any further directions.

I won’t be much help here, I don’t have the asset.

no worries, let’s see if anyone else has any ideas. If not, guess I’ll give it a solo run then :slight_smile:

Hugo (CodeMonkey) has videos on his youtube channel on grid based construction the uses the same grid system he used in the Turn Based Strategy course.

As for the asset, I don’t have it either and there’s an extreme likelihood that I never will.

The way I’d think of building is that you’d have a different ‘inventory’ for building. Games like Valheim, No Man’s Sky, Raft and Grounded have separate lists with building parts. You’re probably not going to walk around with a ‘roof’ in your inventory (although you can) and you’ll need some way of distinguishing between just picking up an item in the inventory vs building with an item. The parts themselves have ‘ingredients’ so it’s a bit like a crafting system where the player can’t build the part if they don’t have the ingredients - unless you have a ‘roof’ in your inventory. TryUseBuildingItem may check if you have the ingredients and if you do it will give you a preview of the item, or it could always give you a preview but keep it red and never allow placing it. I don’t know how the asset works. Instead of a string, I’d use the identifiers we’re already using. There’s no need to add more.

InventorySlotUI is probably not the right place to do this. You are setting the identifier on the slot instead of the item. If there’s an apple in that slot, you are going to try and build with an apple - which is ok, I guess, it’s your game…

And just a quote from a recently blown up creator:

Funnily enough, believe it or not, this is not my first game. My first original game was a tuned version of one of the simpler games back in 2017, by the Unity 3D Course developed by this community (2016 or 2017… don’t remember tbh, I was 18 or 19 back then), before I lost motivation… it was right after I self-taught myself C# on an android app back then, but due to lack of experience (and university getting in the way), I quickly forgot everything.

Following up, I went to create a tower defense game in 2018. It was a single level game, and no saving system. I was following up with Brackeys back then. That one never actually got published because it was created in the short break between semesters, so I never had the time to finish the game off, and then I gave up midway through a course of creating a game similar to PUBG by Brackeys back in the day

Funnily enough though, this RPG course is the first time I dive into something of this shear scale, and actually need to read the code over and over and over and over again, just to understand what’s going on. So… yup, not my first game, but it’s definitely my first time seeing some serious complex logic come into play to make something work, and that includes your crafting system as well (to this day, it still baffles me how everything came along. Clearly you’re skilled man, and great job to you for that!).

Even if it doesn’t work in the end (I hope this one works though), the amount of experience gained here is what I really got in the end. Everytime something doesn’t work, or Brian takes time to respond, I just go investigate things and try solving them myself (I could be an impatient person sometimes, so why not use that for good?)

That one kinda made me laugh tbh… Anyway, I get the point, it goes to ‘InventoryItem.cs’ :slight_smile:

Speaking of the YouTube channel, are you talking about this video? :

The plan was to actually be walking around with ingredients, which get deducted from your inventory whenever you build something, as long as you got the level

Speaking of the asset, I still have faith it’s possible, BUT… The developer can take some time to respond (one thing I never struggled with here tbh). He claims that he actually did the conversion for the ‘RPGBuilder’ asset in Unity, so I’m guessing he can help with this one too. Anyway, I’ll probably try something on my own, if I can get my head around it (and believe me, considering how easily I can lose focus on anything by default nature, this will be hard for me, but at this point in time, I just want to get it done…)

My main problem is, I can’t even get the first step to work in the Repo of the master RPG Copy I have for some reason…

That one can work. This playlist is about his grid system and includes videos for building using it.

I had a quick glance at the documentation and it seems like you should be able to do whatever you need by just following those.

Whilst I agree with you on that, because I got it to work on a blank project, but for some reason… even the first video of that one does not seem to be working for me (on my testing copy of the RPG Project, which is basically the master copy Brian supported us with in his third person implementation). That’s where I’m currently stuck: Beginner's Guides - Easy Build System (Edit: I deleted the entire system and re-set it up in my game, seems to be working well now)

The whole idea I had in mind, was to use inventory resources to construct parts on the go, as we place them in the game world through a grid-based system… That’s it (so everytime you construct something in the game world, resources from your inventory get deducted, and you build something)

That’s an interesting assumption. The RPGBuilder asset in Unity takes a different path than our RPG course. The only way he’ll be able to make an integration with the RPG Course series is if he is familiar with our RPG Course series.

You do know that the knowledge gap between the projects you listed before (unfinished unpublished tutorial projects) and the complete RPG course is… a bit like taking picking up a guitar, learning a few basic scales, and then attempting to play Dream Theater’s The Alien on the first try the next day, don’t you? :slight_smile:

I’m just re-reading the scripts over and over and over again, combined with what the developer said, to try and figure out which functions can be of use for that. It’ll take a few tries, but I think it’s possible. All I need out of this is a way to consume resources from the inventory when the player builds something, that’s it

(and I might actually build a similar tab to the abilities we had, just to host the building parts that can be built, based on what the player has in his inventory… still trying to figure out exactly what I’m going to do there)

true, but again… I do realize that a project this complex is also a plethora of experience, which hopefully will be of extreme help down the line :slight_smile: (if I wanted to give up, I would’ve done that months (or years now) ago. I’m motivated to get this project done now, for a reason (that I’m too far in this to give up now :stuck_out_tongue_winking_eye: )), and I’m taking all advice you guys give me to make this as player-friendly, fun, and polished, as possible.

I did the same for Blender, I started off with one of your courses using Blender 2.79b, and before you know it, I made every single detail on this car from scratch (again, following a tutorial), back in 2019-2020… Now, can I do that again today? Probably not, but I can always revise the lessons for that and try when needed:

And the same goes with the RPG Project. It’s better to know something than not knowing and needing it

Are we picking up the guitar using ‘ClickablePickup.cs’ or ‘PickupTarget.cs’?

My guitars use HumbuckerPickups and SingleCoilPickups. Despite 40 years of playing, I’m still not ready to play The Alien

1 Like

I’m sure you have your own unique taste though. More importantly, does your sphere collider have ‘isTrigger’ enabled, so you can pick it up when in range, or are we using Spider webs? :laughing:

Sphere colliders cause too much feedback, which triggers the sound technician… Can’t go wrong with a good shielded cable, but make sure that shield has at least 20 points of defense. :stuck_out_tongue:

1 Like

Gonna need that defence tbh

Btw, do you happen to know of any good snapping algorithm? Some of my parts are flying here, and although he mentioned that there’s snapping, I’m a little baffled on how it works… I found where it goes, just don’t know what to write :sweat_smile:

I do… you can find it in our Turn Based Strategy Course by CodeMonkey right here at Gamedev.TV.

not a bad pitch :laughing: - but sure, I’ll have a look at it

btw try this song sometime:

It’s a really good one, and it’s helping me through this chaos of this project nowadays :slight_smile:

as much as I’d love to admit that’s true, the saving system says otherwise… for the moment, not even the basic saving system works for some reason (it used to work… idk what I did, but it was probs something bad :sweat_smile: - even reimporting the script didn’t help), and then I have the challenge of trying to integrate that to our game

it’s a headache :stuck_out_tongue_winking_eye: (it does come with a ‘BuildingSaver.cs’ script, but experience with this course is telling me to work on the saving system in the ‘BuildingPart.cs’ script…)

P.S: How do you guys “add” a “JsonUtility.ToJson(saveData)” to a “saving system”? It’s what the dev told me, and I’m not dealing with Capturing and Restoring JTokens here… :sweat_smile: (and I can’t find anything on the internet that tried this before, so it’s… hard, to say the least)

He’s saying that once the data in the EasyBuild has been captured by it’s own saving system, you can convert that data into a Json string.
Under the hood, all Json is in actuality a string. Json is the format that data takes within that string. This means you can return JsonUtilty.ToJson(saveData).ToString() in a CaptureState.

The CaptureState he has is a function known as “Save()”, an IEnumerator. Do we keep it there, or do we have to create a ‘CaptureAsJToken()’ and ‘RestoreFromJToken (…)’ function? (His saves are scene-based, so it carries on independent of save files, and sometimes it works, and sometimes it doesn’t… by far, the weakest link of this system)

I tried placing it under the ‘PersistentObject’ prefab we have, still didn’t work, and he’s been away for well over 24 hours so far (and I’m at this point where I won’t move forward with this integration until this is fixed)

As it’s scene based, you probably want an object in the scene that is a saveableentity, with a component to capture/restore that gets the save result and returns it, and calls whatever load it uses passing in the result of RestoreState.

Privacy & Terms