Hey so here is a quick writeup on these brand new components and what they do (and don't)
First of all we split the existing
SkookumScriptComponent into two new components:
- The most important type of component is the
SkookumScriptClassDataComponent. It exists because by default, SkookumScript does not know when an
Actor (or any
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
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.
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
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.
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 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 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.
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
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!