Constructor not called

Hi, I’m brand new to Skookum Script. First thank you for this programming language and all your work. And second I ran into a problem. My constructor is not called ! :frowning_face:
I have a C++ character class, I do a bluprint directly inherited from this class. And I’ve added a constructor (!) with a simple println(“Run Character Constructor”) on the C++ class in Skookum.

Then when I press play, it spawn my blueprint character, but in skookum I don’t get the “Run Character Constructor” displayed in the console.

So I don’t know if I need to create a Skookum constructor fo my BP class or not ?

Hi and welcome!
I’ve gone ahead and filed this bug.

Some information and a few workarounds for you.

  • The C++ constructor does not have an exact equivalent in :sk:.
  • The BP Construction Script, which is the C++ OnConstruction(const FTransform& Transform) does not have an exact equivalent in :sk:.
  • The :sk: constructor ! is called during InitializeComponent in the C++ world. It is a constructor of sorts, in that it is called when the :sk: stuff is ready to go, but don’t think of it as equivalent to either the C++ or BP construction entry points.

One side-effect of this is that it’s not possible to override the C++ constructor or the BP construction script from :sk:.

Here are 2 ways to mitigate the issue.

Solution 1

Create ! on all classes in the chain

  • Define ! in your base C++ class
  • Define ! in all subclasses in the chain, calling the direct superclass from each constructor e.g. MyCustomCharClass@!()

Solution 2

  • Add ! directly to the subclass only

In general, be careful of getting into a situation like this:

Class Has Constructor?
ClassA true
|-ClassB false
   |-ClassC true

Stick with Solution 1 and you will be fine.

1 Like

Thanks for the quick answer :smiley:, I did apply solution 1, but I was wondering if it was a bug on my computer the way :sk: work !

1 Like