Trouble displaying a Variable
-
- Posts: 15
- Joined: Sat Feb 07, 2015 5:52 am
Trouble displaying a Variable
Back to the sequencer commands for a moment...
I'm using the 'Sprites Unity' animation engine, so wasn't sure if Animation() or AnimationPlay() was appropriate. Still, both failed on me. I'm trying to get my NPC to play animations during the conversation.
I get this compiler error.. "Dialogue System: Lua code 'Animation(D2_2c)' threw exception 'Invoke function call on non function value."
I also tried using AC(Driver) - 'Driver' being an AC ActionList I've created. And got this compiler error... "Dialogue System: Lua code 'AC(DriverAnimate)' threw exception 'Invoke function call on non function value.'"
I'm obviously using this incorrectly. But now I'm curious, how do these sequencer commands know where the animation or ActionList is located without giving it a directory/file location ?
I'm using the 'Sprites Unity' animation engine, so wasn't sure if Animation() or AnimationPlay() was appropriate. Still, both failed on me. I'm trying to get my NPC to play animations during the conversation.
I get this compiler error.. "Dialogue System: Lua code 'Animation(D2_2c)' threw exception 'Invoke function call on non function value."
I also tried using AC(Driver) - 'Driver' being an AC ActionList I've created. And got this compiler error... "Dialogue System: Lua code 'AC(DriverAnimate)' threw exception 'Invoke function call on non function value.'"
I'm obviously using this incorrectly. But now I'm curious, how do these sequencer commands know where the animation or ActionList is located without giving it a directory/file location ?
Trouble displaying a Variable
Hi,
For the script, put this line at the top of the file:
using UnityEngine;
Put sequencer commands in the Sequence field, not the Script field. The Script field is for Lua code, such as conditions on dialogue entries. The Sequence field is for sequencer commands.
For the script, put this line at the top of the file:
using UnityEngine;
Put sequencer commands in the Sequence field, not the Script field. The Script field is for Lua code, such as conditions on dialogue entries. The Sequence field is for sequencer commands.
-
- Posts: 15
- Joined: Sat Feb 07, 2015 5:52 am
Trouble displaying a Variable
Added that to the top. Now I've got this...
"Assets/WatchScale.cs(16,68): error CS0246: The type or namespace name `AdventureBridge' could not be found. Are you missing a using directive or an assembly reference?"
Also, my bad on the Sequencer. It's in the right area now, I've written this - AnimatorPlay(D2, Driver) - 'D2' is the custom animation, tested in AC and it works, and 'Driver' is the character name. This is my new error - "Dialogue System: Sequencer command component not found: SequencerCommandAnimatorPlay()"
My 'Driver' gameobject has a child object containing a Sprite Renderer and Animator. Does it make a different if the Animator isn't on the 'Driver' root object?.
"Assets/WatchScale.cs(16,68): error CS0246: The type or namespace name `AdventureBridge' could not be found. Are you missing a using directive or an assembly reference?"
Also, my bad on the Sequencer. It's in the right area now, I've written this - AnimatorPlay(D2, Driver) - 'D2' is the custom animation, tested in AC and it works, and 'Driver' is the character name. This is my new error - "Dialogue System: Sequencer command component not found: SequencerCommandAnimatorPlay()"
My 'Driver' gameobject has a child object containing a Sprite Renderer and Animator. Does it make a different if the Animator isn't on the 'Driver' root object?.
-
- Posts: 15
- Joined: Sat Feb 07, 2015 5:52 am
Trouble displaying a Variable
I messed around and at least got it to say this...
"Dialogue System: Sequencer: AnimatorPlay() command: subject is null."
"Dialogue System: Sequencer: AnimatorPlay() command: subject is null."
-
- Posts: 15
- Joined: Sat Feb 07, 2015 5:52 am
Trouble displaying a Variable
3859 wrote: I messed around and at least got it to say this… “Dialogue System: Sequencer: AnimatorPlay() command: subject is null.”
Unticked "Disable Internal Sequencer Commands" in the Camera Settings to get that instead.
Unticked "Disable Internal Sequencer Commands" in the Camera Settings to get that instead.
Trouble displaying a Variable
For the script, try this. I'm out of the office at the moment, so I can't test it. If you get any compiler errors, let me know.
using UnityEngine;
using PixelCrushers.DialogueSystem;
using PixelCrushers.DialogueSystem.UnityGUI;
using PixelCrushers.DialogueSystem.AdventureCreator;
public class WatchScale : MonoBehaviour {
public GUILabel scaleLabel; //<--Assign this.
void Start() {
DialogueManager.AddLuaObserver("Variable['scale']", LuaWatchFrequency.EveryDialogueEntry, OnScaleChanged);
}
void OnScaleChanged(LuaWatchItem luaWatchItem, Lua.Result newValue) {
scaleLabel.SetUnformattedText(newValue.AsString);
var bridge = DialogueManager.Instance.GetComponent<AdventureCreatorBridge>();
bridge.SyncLuaToVariables();
}
void OnConversationStart(Transform actor) {
var value = Lua.Run("return Variable['scale']");
scaleLabel.SetUnformattedText(value.AsString);
}
}
The AnimatorPlay() sequencer command will search for an Animator component on child GameObjects. Make sure the GameObject name is exactly "Driver", including case, and the GameObject is active.
If Driver is the speaker (actor) or listener (conversant) assigned to this dialogue entry, you can use "speaker" or "listener" in place of the GameObject name. This way, AnimatorPlay() doesn't have to search the scene for the named GameObject.
using UnityEngine;
using PixelCrushers.DialogueSystem;
using PixelCrushers.DialogueSystem.UnityGUI;
using PixelCrushers.DialogueSystem.AdventureCreator;
public class WatchScale : MonoBehaviour {
public GUILabel scaleLabel; //<--Assign this.
void Start() {
DialogueManager.AddLuaObserver("Variable['scale']", LuaWatchFrequency.EveryDialogueEntry, OnScaleChanged);
}
void OnScaleChanged(LuaWatchItem luaWatchItem, Lua.Result newValue) {
scaleLabel.SetUnformattedText(newValue.AsString);
var bridge = DialogueManager.Instance.GetComponent<AdventureCreatorBridge>();
bridge.SyncLuaToVariables();
}
void OnConversationStart(Transform actor) {
var value = Lua.Run("return Variable['scale']");
scaleLabel.SetUnformattedText(value.AsString);
}
}
The AnimatorPlay() sequencer command will search for an Animator component on child GameObjects. Make sure the GameObject name is exactly "Driver", including case, and the GameObject is active.
If Driver is the speaker (actor) or listener (conversant) assigned to this dialogue entry, you can use "speaker" or "listener" in place of the GameObject name. This way, AnimatorPlay() doesn't have to search the scene for the named GameObject.
-
- Posts: 15
- Joined: Sat Feb 07, 2015 5:52 am
Trouble displaying a Variable
That's done it! - Scale number is displaying.
Thank you very much.
Still no joy with the AnimatorPlay() command though. Checked the case and name and all that. It's all correct. Now it's not even showing a compile error any more, just moves past that point in the conversation as if nothing was there.
As a test I replaced it with an AC() command, pointing to an ActionList in the Resources folder and it worked! So something odd is still happening with AnimatorPlay().
If we can't get AnimatorPlay() to work I'm happy to just stick with the AC() command. At this point I'm just happy it's working However, is it possible to put the ActionList anywhere else instead of the Resources folder and point the AC() command to it? Seems a bit restrictive to have all my ActionLists in one folder.
Thank you very much.
Still no joy with the AnimatorPlay() command though. Checked the case and name and all that. It's all correct. Now it's not even showing a compile error any more, just moves past that point in the conversation as if nothing was there.
As a test I replaced it with an AC() command, pointing to an ActionList in the Resources folder and it worked! So something odd is still happening with AnimatorPlay().
If we can't get AnimatorPlay() to work I'm happy to just stick with the AC() command. At this point I'm just happy it's working However, is it possible to put the ActionList anywhere else instead of the Resources folder and point the AC() command to it? Seems a bit restrictive to have all my ActionLists in one folder.
Trouble displaying a Variable
You can have as many Resources folders as you want, and you can also refer to action lists in the scene itself. For example, in the AC example scene, you can run the "Try lifting" cutscene.
For the AnimatorPlay() sequencer command, when you get a chance set the Dialogue Manager's Debug Level to Info. Then reproduce the issue and post the editor.log file or email it to tony (at) pixelcrushers.com.
For the AnimatorPlay() sequencer command, when you get a chance set the Dialogue Manager's Debug Level to Info. Then reproduce the issue and post the editor.log file or email it to tony (at) pixelcrushers.com.
-
- Posts: 15
- Joined: Sat Feb 07, 2015 5:52 am
Trouble displaying a Variable
Emailing you the editor.log file now.
Watching the console window as it went I can see that it calls the function, but nothing happens onscreen.
Also, just to make things more fun, even weirder things are happening with the AC() command. Everything works fine, but sometimes it says "cannot find <insert action list here>" and doesn't work. But it's clearly there and has worked before. Without changing anything in my scene, I rename the file in Finder and immediately rename it back to it's original name. Now it works again. WTF?
Watching the console window as it went I can see that it calls the function, but nothing happens onscreen.
Also, just to make things more fun, even weirder things are happening with the AC() command. Everything works fine, but sometimes it says "cannot find <insert action list here>" and doesn't work. But it's clearly there and has worked before. Without changing anything in my scene, I rename the file in Finder and immediately rename it back to it's original name. Now it works again. WTF?
-
- Posts: 15
- Joined: Sat Feb 07, 2015 5:52 am
Trouble displaying a Variable
Ok, more weirdness.
I've been using a Continue button to advance through dialogue. I've got the Continue Button (in Subtitle Settings) set to 'always'. I just changed it to 'never' and now the AnimatorPlay() function is working!
By this point I'm so confused. The WatchScale script is working consistently though, which is nice.
I've been using a Continue button to advance through dialogue. I've got the Continue Button (in Subtitle Settings) set to 'always'. I just changed it to 'never' and now the AnimatorPlay() function is working!
By this point I'm so confused. The WatchScale script is working consistently though, which is nice.