Hi,
I would like to call a function with parameters (a string) of a script on a game object in the scene right at the moment when the choice menu appears, because I would like to instantiate a GameObject during the time the player is faced with the choice. How could this be realized? Thanks!
Call function in script right at the moment when choices appear.
-
- Posts: 4
- Joined: Tue Jun 20, 2023 2:18 pm
Re: Call function in script right at the moment when choices appear.
Use a sequencer command. You can write a custom sequencer command to call your function, or -- if the function accepts no parameters or a string parameter -- you can use the SendMessage() sequencer command. For example, if your function is on a GameObject named "Hourglass" and the function is named "Flip()", you could use the command:
There are two points at which you can use the sequencer command:
1. At the end of the preceding dialogue entry's Sequence.
2. Or add a Response Menu Sequence to the preceding dialogue entry and use it there.
I'll go with #1 for an example. Let's say you don't require the player to click a continue button to advance the conversation. Instead, you want to advance to the response menu as soon as the subtitle panel's typewriter finishes typing. Then set the preceding dialogue entry's Sequence to:
The "required" keyword guarantees that the command runs even if the player skips ahead somehow.
Code: Select all
SendMessage(Flip, , Hourglass)
1. At the end of the preceding dialogue entry's Sequence.
2. Or add a Response Menu Sequence to the preceding dialogue entry and use it there.
I'll go with #1 for an example. Let's say you don't require the player to click a continue button to advance the conversation. Instead, you want to advance to the response menu as soon as the subtitle panel's typewriter finishes typing. Then set the preceding dialogue entry's Sequence to:
Code: Select all
required SendMessage(Flip, , Hourglass)@Message(Typed)