SetTimer and Kismet Node Action

I’ve written a kismet node with variables that can be edited through kismet. I want to reference these variables in a class inside PlayerController.uc. I also want to add a delay after a certain action, and to do that I use the SetTimer() function. The problem is SetTimer can’t call functions with arguments, and I must reference the kismet node in each function to be able to use the variables inside it (as far as I’m aware). Here’s some code to explain what I’m talking about:

SeqAct_TestNode.uc


class SeqAct_TestNode extends SequenceAction;

var() string TestVariable;

defaultproperties
{
ObjName="Test Node"
ObjCategory="Test"
VariableLinks.Empty
VariableLinks(0)=(ExpectedType=class'SeqVar_Object',LinkDesc="Target",PropertyName=Targets)
}

PlayerController.uc


function OnTestNode (SeqAct_TestNode Action)
{
     // Do something here
     SetTimer(1.5, false, nameof(DelayedFunction));
}

function DelayedFunction (SeqAct_TestNode Action)
{
     Action.TestVariable = 5;
}


This doesn’t work because the function DelayedFunction needs a parameter Action to work, and you can’t call functions with parameters through SetTimer. Does anyone have any suggestions on how to get around this?

What I always do is make a class variable, set it when I set the timer, and then use that variable when the function gets called.



var string TestString;

 function OnTestNode (SeqAct_TestNode Action, optional string NewTestString = "Default String")
{
     // Do something here
     SetTimer(1.5, false, nameof(DelayedFunction));
     TestString = NewTestString;
}
 function DelayedFunction (SeqAct_TestNode Action)
{
     Action.TestVariable = TestString;
}


That wouldn’t work if you set the timer again before the original timer goes off, but there are ways around that too.

Yeah that’s the only thing I could come up with. I was looking for another solution because there’s a lot of variables in this kismet node and this is really messy, but if it’s the only way to do it it’s better than nothing. Thank you so much for the help!

I may need additional help. One of the variables in the kismet node is a struct. When I try to copy the struct from the node to the global variable I get an error. Am I doing something wrong?

SeqAct_TestNode.uc


class SeqAct_TestNode extends SequenceAction;

struct TestStruct;
{      
      var() int TestInt;
      var() float TestFloat;​​​​​​
}
var TestStruct Example;

defaultproperties
{
     ObjName="Test Node"
     ObjCategory="Test"
     VariableLinks.Empty
     VariableLinks(0)=(ExpectedType=class'SeqVar_Object',LinkDesc="Target",PropertyName=Targets)
}

PlayerController.uc


struct TestStruct;
{
     var() int TestInt;
     var() float TestFloat;​​​​​​
}
var TestStruct NewExample;

function OnTestNode (SeqAct_TestNode Action)
{
     NewExample = Action.Example;
}

Error, Type mismatch in ‘=’.

Declare the struct once, then in the other class that you want to have the same struct, declare the class like this:



class PlayerController extends Controller dependson SeqAct_TestNode;


That did the trick. Thank you so much!