Confused with hierarchies


#1

Hi there! I’m trying to learn SK, made all the tutorials and checked the demos. Everything is great but when you want to do something by yourself it gets really frustrating, as everything is a bit confusing for non c++ hardcore programmers.

So, for example I’m attaching a ScriptBehaviourComponent (derived from that class, obviously). The problem comes when I want to make some behaviour to the parent class where the script is attached. Let’s say for example, rotate that class . It should be the “parent” or “owner”, right? But if I try to access the owner for calling methods I get “Tried to invoke method ActorComponent@owner but the Actor Component is null”.

The fact is that I tried to do the same by making a ActorComponent child instead of ScriptBehaviourComponent and it works.

So, the owner of the ScriptBehaviourComponent is “ActorComponent” instead of the BP Class that is attached to?

Who owns who and why? How can I easily access to objects and get the control over the hierarchies?

PS: This is being harder to learn for me than other languages/engines. I think little examples of separated functionality would be extremely helpful.You can learn easier and assimilate stuff playing with small scenes in that way rather than trying to figure what the verbose documentation mean :smiley:

Thank you very much!


#2

Hi @grumoth thanks for trying out SkookumScript! Did you have a look at this post? It explains the different SkookumScript components in more detail.


#3

When did you invoke your method? In the constructor of the component? Try overriding the on_attach method for the invocation of methods, or try something like this in the constructor…

branch [
  // wait for the owner to be instantiated, sometimes the component is instantiated first
  loop [if not owner.null? [exit] _wait]
  //insert code to do stuff to the owner here
]

you can also use the valid? method


#4

Heyy thanks a million! This is exactly what was happening :slight_smile: .I have to be more careful with those things.

Cheers!