Need Blueprint logic advice for Conditional Checks before creating Objects

Before anything I would like to apologize for the confusing Title, but I do not know how to summarize the question in a few words.

This is the scenario:

  1. I have a list of Perks (Actor Components) that Players can get for various game objects
  2. Some Perks have conditions for them to be usable by specific game objects
    2.1) Condition Example 1: game object have to be above Lv 3
    2.2) Condition Example 2: game object already has specific perk
    2.3) Condition Example 3: game object is a specific game object
  3. Player can roll for a random Perk, and can only roll for Perks that has their conditions met

What I have:

  1. I have a base Perk class that has a function “IsUsable”, that returns a boolean, which returns True by default
  2. For Perks with conditions, I override that function with the conditions
  3. When rolling for Perks, I intended to check if the Perk using the function “IsUsable”

However, in order to access the function, I will need to create an instance of the Perk first.

So here are the questions:

  1. Is there a better way to achieve the result?
  2. Is there some where I can make it so that the function is accessible without an instance
  3. Is creating an instance of every Perk (Actor Component), and attach them to some arbitrary game object, and access the function from there?

Would querying Class Defaults be enough in this case?

Before spawning the perk, ask its class for default values - some form of compatibility data → push that into a function library, process against other perks. Could that work?


I wonder if what you’re asking is a good fit for:

From how I imagine the implementation, class defaults is not suitable because:

  1. The condition relies on external parameters, and they may change over time.
    1.1) Example 1: game object Level goes up, and the Perk becomes acquirable
  2. I want to keep the conditions within the “Perk” class, so that they can be inherited

I don’t really see how a Global function library is going to work, aside from handcrafting which Perk should use which condition for every Perk in a Perk manager of sorts.

I honestly am not familiar with Tags, but if they are what they sound like to me, it seems like you will still need to handcraft them the same way as stated above, but can at least check if a Perk has a specific tag to know if you want to run a certain condition in the Perk manager.
I will explore the tag functionality a little.

I do appreciate the insanely quick reply by the way.
I couldn’t do the same because I am considering the possible solutions with the tag feature.
Also, if I seem like I am misunderstanding your intention for any of the solution above, do let me know.

1 Like

You got me right, that’s what I was thinking.

Are you fine with using C++?

If so, make a static function in the Perk class that takes a TSubclassOf<UPerk>, as well as a target object (AActor*)

Then in the function, you get the DefaultObject of the Perk class, and you run the IsUsable function on it, pass the target actor as well, do the relevant calculations and return appropriately

This is how GAS checks for if abilities can activate

I have no experience in C++, but will look into it if it cannot be solved with just blueprint.
I will look into static functions.

Honestly, I thought a “GAS check” is common enough that Blueprints will have solution for it in some way, if I am understanding what GAS check it correctly.