How to query the state of a C# variable?
I would like a branch in my tutorial to be conditional on the state of the game, which can be queried from a C# variable. What is the best way to do this in Tutorial Designer? The only approach I that I can think of is to have a Step Node call in action which tells some C# code to call the event manager to send a trigger event that a subsequent event node listens for. Is there any approach that would be more straightforward? Thanks!
you don't need a StepNode for triggering an event. You can do that anywhere in your code, like this:
What I would do is to pass the variable name as parameter in this call above. Maybe in your Start() function or somewhere else. Then you can simply create one Event node with two or more triggers. Each trigger will be a fork in the tutorial. That's the simplest way I can think of. Hope that helps.
Thanks very much for your response.
When I try calling TutorialDesigner.EventManager.TriggerEvent() in Start(), the Event node does not get triggered by it. Doing it this way there is a minute or two of elapsed time between Start() and reaching the Event node. I did get this to work by putting a Step node before the Event node and having the Step node send an event to call a function that results in TriggerEvent() being called 1 second later.
So, a question: Do calls to TriggerEvent() result in the trigger being "persistent" so that an Event node can react to the trigger at a future time, or does TriggerEvent() need to be called when the Event node is already active and waiting for a trigger?
Thanks again for your help,
if no StepNode is connected, it's a global EventNode. So it listens always to all events that are triggered in your game. If it's connected to a StepNode, it only listens at the active step.
If you call it in Start(), then you have to make sure that TutorialDesigner has already initialized when triggering. Or you could add a little delay to the function etc.
Thanks for your reply and apologies for the long delay before I got back to this thread.
I am still wondering what will happen in this sequence:
- Call TutorialDesigner.EventManager.TriggerEvent("eventname");
- A couple of minutes pass while the tutorial continues to execute.
- An EventNode is reached that is triggered by "eventname."
Does the EventNode in #3 receive the trigger from #1, or was the trigger transient and gone?
EventNode in #3 will receive the event, only if it's active. You can see it in the Editor Window, whether or not it is active and framed yellow. If the event node is not active (anymore), it won't receive the event and do nothing.
Thanks, Michael. This helps me understand how the sequencing works.