How do I expose the derived class variables in blueprint while storing in an array of its base class?

I have an array storing a base type class, let’s call it “Animal”. Yet I’m deriving from Animal to create an alligator with a bite strength variable, a human with a brain power variable, and a turtle with a life span variable. How can I, in the blueprint’s details panel(not code), be able to edit this Animal array and put inside 2 turtles, 3 humans, and 1 alligator, and being able to edit these derived variables? Is it possible? Or will I have to create an array of alligators, an array of turtles, and an array of humans? If I were using unity, I could create a custom inspector which allows me to expose variables as i see fit, using code, so to fix this problem I would use an enum in the base class to dictate what class to cast to, and cast it before exposing it. So then, when I click on the object in the scene, the inspector changes its interface of each array element depending on the enum I choose for them. I’m just not sure if unreal has this type of custom inspector feature.

Thanks ahead of time.

You can store all your animals in an array of that base class and then when you need a derived variable you can cast to the animal type you need. Moreover you can use interfaces, components, and tags as other means to group data within an object if you prefer to avoid casting.

I think I must have asked the question incorrectly. I need to access these variables using the blueprint details panel, not from code. If I were using unity, I could create a custom inspector which allows me to expose variables as i see fit, using code, so to fix this problem I would use an enum in the base class to dictate what class to cast to, and cast it before exposing it. So then, when I click on the object in the scene, the inspector changes its interface of each array element depending on the enum I choose for them. I’m just not sure if unreal has this type of custom inspector feature.

I do not believe Unreal has that feature. If it’s completely needed you could always change how the editor works.

Between the options I mentioned there are a lot of ways to work around writing a custom inspector but it all depends on your specific needs.

Welp, hmmm, I guess my needs are the following:
I have an array of actions a character can make, it’s an action 3rd person view. The base class is “CharacterAction” and his actions can be as varied as transform into a monster, to jump, to charge an attack, to taunt. These highly varied actions are derived from the base action and all act upon the character in different ways. These actions need to be tweaked with values and with animation montage links, and collider links and such. I’m hoping to have 1 array of actions stored in the player, and in the inspector edit them accordingly. With this I would be able to add actions as if they were components and with a virtual interface that would allow me great flexibility and organization, especially since there might be other people working on different actions. Heck, the basic “SimpleAttack” action will likely have 10-20 different variations and activation methods… Am I going to have to make an array of each action class and handle each one accordingly instead? 8,(. Ah, I’m new to the new unreal, so I wouldn’t know the first thing to seeing how I can change how the editor works X p but thanks for the vote of confidence on that X,p.

I hope I’m wrong about Unreal not having that feature but here’s three ideas that might help

1- Organize your data in a general fashion in a nested array of structs using simple Name-Value pairing. I know it might sound messy and dumb but it can go a long way; in one of my project I’m using an array of Goals (actions) which contains an array of Decision Heuristics (reasons why to choose that action). This makes my project very extensible as some units can do dozens of actions and are influenced by dozens of different heuristics.

53438-arrayofstructsofstructs.png

2- Create components that drive your different actions. For example a WerewolfComponent and during runtime when the user becomes a werewolf you active it and enable input to it. Thus when the player presses Left Mouse Click it then consumes the input to do your special attack and you could add whatever other custom wererwolf logic you want.

3- Lastly, try to always put logic where it best works with the engine. I only say this because you brought up actions being assigned animations. More explicitly, I would suggest having the animation blueprint handle playing animations/montages and not where you set the logic of which actions your character can take.

That’s just my suggestion though, hope it helps!

thanks I’ll consider these (nods profusely). I’ll keep the question open though, just in case someone knows if what I’m trying to do is possible.