[RESOLVED] When to use the SkookumScript* classes/component?


Hi, I was wondering if someone could explain a bit about when I should (or shouldn’t) be using the SkookumScript* classes - i.e. SkookumScriptClassDataComponent, SkookumScriptMindComponent and SkookumScriptBehaviorComponent

I’m just getting started, but so far haven’t touched any of those SkookumScript* ones, rather have been adding :sk: functions directly on to my existing user-defined classes and components (typically c++ ones, sometimes the blueprints that inherit from the c++ ones).

I’ve read a thread on them - SkookumScriptClassDataComponent, SkookumScriptMindComponent and SkookumScriptBehaviorComponent - who is who - but I’m having trouble picturing the situations where I’d use those rather than directly extending an existing class with :sk: functionality.

It seems like something worth getting my mind around before going too much further!


Hi - as you read in the overview, each of the components has a different purpose.

The most important type of component is the SkookumScriptClassDataComponent. It exists because by default, SkookumScript does not know when an Actor (or any Entity[=UObject]) get constructed or destructed in the engine. So for example if you created a BP class Hero derived from let’s say Character and give it a SkookumScript constructor that constructor would never get called, unless a SkookumScriptClassDataComponent is added in its Blueprint. Then, upon construction of that Actor, the SkookumScriptClassDataComponent also gets constructed which invokes the SkookumScript constructor. Same is true for the destructor. The SkookumScriptClassDataComponent also allows you to assign a pure SkookumScript class to an Actor, e.g. a SkookumScript class SuperHero which is derived from Hero that has no BP class equivalent.

The SkookumScriptMindComponent is very similar except that it creates a Mind class along with the Actor and destroys it along with the Actor which is helpful if you want to control the instantiation and lifespan of a Mind using a proxy Actor that is for example part of your level.

The SkookumScriptBehaviorComponent is meant to attach a temporary behavior to an actor. So the idea is you attach it and your actor starts doing something controlled by the component. You detach the component and it stops doing it.

Hope this clears things up!


Thank you, yes that helps a lot! The other thread explained the “what” very well, but I understand the “why” much better now too and can see where these would be very useful.


I’m thinking the skookumscriptmind component would be the place to run the state machine for a worker actor. That way each worker would be independent of the others. Or, I could branch to a coroutine in the Sk constructor for the class and let the master mind manage it. It seems like a mind local to the actor would have less risk of coroutines continuing to run after the actor is destroyed, though. I should probably mention that there could be hundreds of workers active at one time. Any guidance on this?