Setting the Skookum Class Name in BP


#1

Hi guys! I was just working in blueprints, and I was going to set actor class name in the construction script, but there appears to be no way to do that. Am I doing something wrong, or is this by design? My plan was to have different Skookum classes for different missions, and only need a minimal number of blueprints because it’d just be setting a string on a spawned default misson BP, with a SkookumClassDataComponent.


#2

I believe what you are trying to do is currently not possible. We’ll think about it some more though and see if we can come up with a solution.

Alternatively, you could use a set of SkookumScriptBehaviorComponents to control the behavior of your actor. You create a few different SkookumScriptBehaviorComponents that implement different behaviors. When the actor is spawned (between begin_spawning_actor and finish_spawning_actor), you pick one of them to attach to your actor.


#3

That seems doable, but at the same time having the whole option of Skookum only classes seems to need a way to pick the actual class at the initialization of the Actor. I really think having this option is handy for a multitude of uses. You could do enemies with different logic, player skills that all use the same bp, but a different Skookum class, etc…

Is there a way to spawn the actor with a specific class from Skookum? Because I could easily just make a workaround function that spawns a class through Skookum and sets it from there. If not, was the only intended use for actors placed in the map?

[EDIT] Just wanted to note that I tried spawning a Skookum only class, and it threw an error saying the class did not exist. Shouldn’t it by default just spawn the first Blueprint class with that Skookum logic? Like with the following hierarchy Quest_BP->Is the parent of ->SkookumQuest so spawning SkookumQuest should spawn a Quest_BP actor with the SkookumQuest logic… Right?


#4

We are actually just now working on a fundamental rework of the UE4 plugin class binding system that will make a lot of things easier (e.g. the SkookumScriptClassDataComponent will be no longer needed, properties/spawn parameters can be set directly in the UE4Editor without having to create a Blueprint first, Blueprint events can be directly implemented in Sk without a Blueprint graph etc.). So if you could spawn an actor from an Sk-only class like you attempted (e.g. SkookumQuest), would that solve your problem?


#5

I think it would. I’d need to be able to store the class as a string or some form of variable though. Is there method to cast a String->EntityClass?

[EDIT]
Been digging a bit deeper, and I can’t find a way to convert Strings to a class, but I’ve found object ids. I’ve yet to figure out exactly how to set those up, but will those work with a variable? Because they seem really close to what’s needed, if paired with the ability to spawn an actor with a Skookum class.


#6

Cool that you are starting to dig deeper in to SkookumScript.

There are a couple of things you can do to solve your task right now and as @GreatGuru mentions we have a bunch of new tech being worked on this minute that may help you even more.

It may not be obvious in the sparse documentation that we have, though you can use SkookumScript classes as objects such as: Pawn, Hero, Enemy

So you can store a class as an object and call methods on it. For example:

!spawn_class: Enemy
spawn_class.spawn_at_player

This allows you to do variations such as this

!enemy_classes: {EnemyA EnemyB EnemyC}
enemy_classes.any.spawn_at_player

The only time you might need to convert from a Symbol or String to a class is if you needed to save/serialize out a class. If storing a class in a variable or list, etc. is sufficient then you shouldn’t need such a conversion mechanism.

As you noted, if you try to spawn a SkookumScript class that does not have a mirrored Blueprint class it will have an error and it will not even use the BP info from a superclass that is mirrored on the BP side.

We are working to make all SkookumScript classes that are a subclass of a BP class to do the appropriate BP mirroring for you automatically.

Use BP subclass shells

In the meantime however, one thing you could do is just make some subclasses on the BP side which will be reflected in SkookumScript and automatically make mirrored SkookumScript classes. Then you can modify these SkookumScript classes with new or different routines as you need. Then you can use the techniques discussed above.

Use contained SkookumScript objects for behavior

You could keep your main characters/models as dumb automatons and have different SkookumScript objects that control their behavior. This is the technique that is often done with UE4 controllers. You could make different Mind classes (or other class types - they don’t have to be Mind objects though that makes sense) that you can swap in/out or turn on/off as needed.


Let us know if this makes sense or if you have more questions. :madsci:

Note on Object IDs

Object IDs are used to look up instances of objects that already exist in the world.

Enemy@'RoboChar1

Though they do call the method object_id_find() which could create an object if it didn’t already exist. Not sure if that is crazy talk though. :madsci:

We’ll be putting up more documentation on Object IDs though until then there is a bit about them here:


#7

Thanks for the detailed response! The object id setup totally makes sense, I was only halfway through the docs for them at the time of posting last night. I’ve actually been enjoying @'SomeActorName' for some quick logic testing with out needing to set up variables for actors.

As for BP Shells, it actually doesn’t seem that bad to use a blueprint per mission/quest when I really think about it. At first, I was going to set up a data table with each struct holding a BP class, and an optional Skookum class name. Then the table would be used my NPC’s and job boards. But really, since GetClassDefaults is a thing in UE4, the whole asset library is like a data table, and I’m just over complicating things. I doubt I’ll be making enough missions to really become too much data anyways. I’ll keep playing with it, and see what happens.

#However
If in the future I can just spawn a Skookum class that automatically uses it’s appropriate parent BP, then I think some even more awesome type things will be possible.

Thanks for your help so far, I’ll probably get confused again soon in the future!

BTW, :eye: :heart: :sk: