SkookumScriptClassDataComponent, SkookumScriptMindComponent and SkookumScriptBehaviorComponent - who is who


#1

Hey so here is a quick writeup on these brand new components and what they do (and don’t)

SkookumScriptClassDataComponent and SkookumScriptMindComponent

First of all we split the existing SkookumScriptComponent into two new components:

  1. 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 store data members in an Actor, and assign a pure SkookumScript class to it, e.g. a SkookumScript class SuperHero which is derived from Hero that has no BP class equivalent. Only one such component is allowed per actor.
  2. The SkookumScriptMindComponent allows attaching a custom Mind to an actor (see here for an explanation of what a Mind is in SkookumScript). The Mind gets constructed along with the actor and destroyed along with actor. Attach as many as you like.

Both of these are available as a component to attach to an actor in UE4Editor, however their existence is hidden from inside your scripts and you cannot attach or detach them via script either. The only type of constructor you can use with these components is the default constructor.

So what about the good old plain SkookumScriptComponent? That is now deprecated and should be replaced by either SkookumScriptClassDataComponent or SkookumScriptMindComponent depending on what you use it for. We added a dialog box that will pop up with fixing instructions when a SkookumScriptComponent is encountered in a project. We will eventually remove SkookumScriptComponent from the SkookumScript plugin in the near future.

SkookumScriptBehaviorComponent

Then we created a brand new component called the SkookumScriptBehaviorComponent. It 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. You subclass from SkookumScriptBehaviorComponent to create your own custom :sk: components. You can also subclass from it in C++ (by deriving from USkookumScriptBehaviorComponent) to create your own custom script-enabled C++ component. This component can be attached to an actor in UE4Editor but is also visible from scripts as a :sk: class, and can be attached and detached via script. If you like, you can attach and detach your component several times with the object living on inbetween, potentially doing things even while detached. Attach as many components to an actor as you like. Mix between Blueprint created and script-attached SkookumScriptBehaviorComponents. You can give your custom SkookumScriptBehaviorComponent any constructor you like that can take any number of arguments.

The SkookumScriptBehaviorComponent has the following methods to override with your own:

  • ! (constructor): IMPORTANT You need to call this constructor from the constructor in your derived class via SkookumScriptBehaviorComponent@!() - it does important low-level initialization.
  • on_attach(): Callback that is invoked just after the component has been attached to an actor. Override with your own implementation in your custom component.
  • on_detach(): Callback invoked just before this component is detached from its actor.
  • on_begin_play(): Callback invoked when the component is beginning play, called before its owner’s BeginPlay on Actor BeginPlay or when the component is dynamically created if the Actor has already BegunPlay.
  • on_end_play(): Callback invoked when gameplay for the component ends.

There are also the two methods attach and detach that you can invoke to attach/detach your component to/from an actor.

A typical way to create and attach a component would be MyComponent!(my_argument1 my_argument2).attach(some_actor). Find a SkookumScriptBehaviorComponent on an actor via !my_component: some_actor.component_by_class(SkookumScriptBehaviorComponent.static_class)<>SkookumScriptBehaviorComponent. Detach it via my_component.detach. Or keep a reference to it around.

That’s about it - enjoy! And if you have any questions please ask away!


Is there any progress on Actor Components?
3.0.2822 Beta is out! 4.12 now supported on Marketplace, new components plus lots of new features and bug fixes
3.0.2822 Beta is out! 4.12 now supported on Marketplace, new components plus lots of new features and bug fixes
The Market Place Updated With New Skookum Features!
[RESOLVED] When to use the SkookumScript* classes/component?
Confused with hierarchies
About component oriented programming on SK
#2

I updated and maybe I am misunderstanding something about SkookumScriptBehaviorComponent

I cannot create a blueprint class derived from SkookumScriptBehaviorComponent because it does not show up in the list of classes to derive from when doing Create Blueprint Class

Currently I have components that derive from ActorComponent that have data that needs to be replicated associated with them so it’s declared in the bluerpint. I thought I would update those to derive from SkookumScriptBehaviorComponent so I could get the constructors etc working properly.


#3

I checked a fix into GitHub and P4. Deriving your Blueprint from SkookumScriptBehaviorComponent should now work. Let me know how it goes!


#4

The fix unfortunately introduced a new bug. :confounded: Please sync again to get the fix for the fix! :slight_smile:


#5

Thanks I got my project updated. So far no issues, other than issues with reparenting the blueprints but i created another thread for that.

The components seem to be working as intended with the constructors now working.

Thanks again.


#6

I cannot seem to get attach to work.

I create a blueprint in unreal called Test which is a subclass of SkookumScriptBehaviourComponent. I added nothing to this blueprint at all. I created an actor Mind, inside of the actor Mind I simply call this code:

!warrior_ref: Actor.named("Warrior")

Test!.attach(warrior_ref) //as soon as it hits this line it crashes... it just says fatal error.

#7

Did you call the constructor for the superclass in your Test constructor? And can you please paste the entire error message?


#8

Yes. The error message is exactly as I said:


#9

This bug is fixed and pushed btw. Enjoy! :slight_smile:


#10

Bug is fixed great work Skookum team!