Hey!
Is there a way I can run a function after a node is complete?
I want to enable a function that enables a script once it's reached the end of that node(Which is also the end of the conversation).
Activate function after specific Node
Re: Activate function after specific Node
Hi,
If your function is a C# method, there are two common ways to activate it: as a Lua function in a node's Script field, or using a node's OnExecute() scene event. However, both of these ways run as soon as the node starts.
You could add an empty node to the end of your conversation. Activate the function in that node. Leave the Dialogue Text blank, and set the Sequence to: Continue()
If you can't add an empty node for some reason, another option is to use a sequencer command. If you want to enable a script, you can even use the built-in SetEnabled() sequencer command. For example, say you want to enable a script named MyScript on a GameObject named MyGameObject. If you automatically advance each node based on the duration of the text, you could set the final node's Sequence to:
If you require the player to click a continue button to advance each node, you could set the Sequence to:
If your function is a C# method, there are two common ways to activate it: as a Lua function in a node's Script field, or using a node's OnExecute() scene event. However, both of these ways run as soon as the node starts.
You could add an empty node to the end of your conversation. Activate the function in that node. Leave the Dialogue Text blank, and set the Sequence to: Continue()
If you can't add an empty node for some reason, another option is to use a sequencer command. If you want to enable a script, you can even use the built-in SetEnabled() sequencer command. For example, say you want to enable a script named MyScript on a GameObject named MyGameObject. If you automatically advance each node based on the duration of the text, you could set the final node's Sequence to:
Code: Select all
SetEnabled(MyScript, true, MyGameObject)@{{end}}
Code: Select all
required SetEnabled(MyScript, true, MyGameObject)@Message(Continued)
-
- Posts: 82
- Joined: Wed Mar 31, 2021 6:48 pm
Re: Activate function after specific Node
Thanks for your response Tony.
I was able to use the first approach, however, the gameobject doesn't seem to disable on the node I want it to. I believe this has to do with OnExecute() running the prefab gameobject rather than the gameobject in the scene. Is there a way to use a gameobject from a scene?
To provide some more context, I want the blue ghost to be disabled at the start and only turn on once the last node has run.
I made a function that will do what I want and it DOES work, but it only works in the "Prefab" version of this. (Prefab being in the asset folder). Even if I drag the prefab onto the scene, this method does't run for the object I want it to
I was able to use the first approach, however, the gameobject doesn't seem to disable on the node I want it to. I believe this has to do with OnExecute() running the prefab gameobject rather than the gameobject in the scene. Is there a way to use a gameobject from a scene?
To provide some more context, I want the blue ghost to be disabled at the start and only turn on once the last node has run.
I made a function that will do what I want and it DOES work, but it only works in the "Prefab" version of this. (Prefab being in the asset folder). Even if I drag the prefab onto the scene, this method does't run for the object I want it to
-
- Posts: 82
- Joined: Wed Mar 31, 2021 6:48 pm
Re: Activate function after specific Node
Update
I seemed to get it working by connecting my C# scripts to Lua.
I used this video to help me out:
Thank you!
I seemed to get it working by connecting my C# scripts to Lua.
I used this video to help me out:
Thank you!
Re: Activate function after specific Node
Hi,
I'm glad you got it working.
You can also assign scene objects to OnExecute() events. See Scene-Based Events. This way, you could have assigned the scene instance of the ghost to the event.
Another option that I didn't mention before would be to add a Dialogue System Events to Enti. Configure its OnConversationEnd() event to activate the blue ghost.
I'm glad you got it working.
You can also assign scene objects to OnExecute() events. See Scene-Based Events. This way, you could have assigned the scene instance of the ghost to the event.
Another option that I didn't mention before would be to add a Dialogue System Events to Enti. Configure its OnConversationEnd() event to activate the blue ghost.