Im trying to use the ScriptInstance component to add scripts to nodes. After a few tries, couldnt find a way to properly use them. First I wrote a short AS script with a class, but if I put the class name in the Class attribute in editor, I got an error saying that it needs an interface with ScriptObject. This is the class code:
[code]#include “Scripts/Engine/AIController.as”
class test: AIController
{
void Update(Entity@ e)
{
Print("AICtrl for "+e.Name);
}
}
[/code]
Then I tried with a simple function without class, but then the problem was more strange, it simply freezes the game.
This is the code that gets the component:
if (node.HasComponent("ScriptInstance")){
scr = node.GetComponent("ScriptInstance");
}
Print("script loaded");
For some reason , the game freezes after the Print and only responds to Alt-f4, and Im not even executing the script. If I remove the GetComponent line, it goes back to normal behaviour.
Can somebody illustrate me about how to properly use ScriptInstance components? How can I use Variant to pass a custom class as parameter?