Just to give some context to my issue, I am creating an RTS building style project to learn the ropes.
My issue is with a type of actor I have on my map, in my case it’s a kind of Mineral Deposit, where you place a refinery to mine.
Each mineral deposit can only have one building placed on it at any one time. My mineral deposit actor has a boolean variable, called “In Use”. If a building is placed on it, it is set to True, and no other building can be placed on it. This works as intended.
My issue is that if I drag a second copy of the mineral deposit onto my map, then the boolean logic is shared across all of my Mineral Deposit actors. Once the variable is set to true, it is true in all Mineral Deposit cases.
Some Googling shows that this is a common issue, but I can’t quite get my head around the various aspects of this in relation to my current setup.
I could very easily do a daft workaround, where I create individual mineral deposit clones/child classes, and name them 1, 2, 3, 4, and create separate blueprints for each, but even as a beginner this sounds like a bad workaround.
Here’s my very basic logic at present:
-
True/False “in use” variable is located on the mineral deposit.
-
In my Placeable Building blueprint, it casts to all classes of Mineral Deposit to check if the “in use” variable is set to true before placing. If it is true, it cannot place.
-
If a refinery building is placed on the mineral deposit, then the refinery building casts to the Mineral Deposit class and sets the variable to True.
I suspect the issue is that I am looking at this as a beginner, as my logic is currently casting to all classes of Mineral Deposit, rather than the specific "object"of that class I want to reference. In this case, I assume I need to cast to the specific mineral deposit which is being overlapped by my placeable building.
It’s just how the hell to go around setting the logic :D.
As I have not tried building a shoot-em-up type game yet, I suspect this is a basic issue easily solvable, as each actor would have a health variable, and you would only want to kill the specific actor whose health is 0 or below, rather than all of the actors of the same class suddenly dying!
Thank you for your patience with a learner