Newbie needing help!
-
- Posts: 7
- Joined: Sun Jul 15, 2018 6:24 pm
Newbie needing help!
Hello, I'm a student of game development, and I'm currently finishing a 3 month Unity course and working on my final project, which I decided it to be a Monkey Island like adventure. My teacher suggested trying this system for it, so I'm trying to learn to use it, and it's really an amazing system! pretty much overkill for what I need right now. But since I'm still very new to programming, I'm really lost in what to do now, and can't quite piece together how to do what I need.
For doing the tutorials I learned to make a simple dialogue like in the quick start one, and I already adapted that to my game. But there are still some basic functions I can't quite find, so I would greatly appreciate if someone could guide me a little bit.
Right now, I just need these things:
-How to make a different dialogue for the second time you speak to an NPC. I already know how to "make it" but I can't make it so that one triggers after the first one... (EDIT: Ok I figured this one out using the "only once" and "Exclusive" options of the script, I guess there are better ways to do this... but for some reason these scripts aren't opening in Visual Studio, so I can't add an if or something to trigger them...)
-How to trigger other stuff to happen when certain dialogue appears, what I mean by this, is, for example, I plan to make a very simple inventory system, so if my character has a certain item, he can give it to an NPC and the story continues. So basically I would need the NPC to hand an item to the character after a certain dialogue, but I can't really find how to put that there... same for animations, I have some ready to make things like, when the NPC says "No" an animation of him shaking his head triggers, the same could work for dialogue.
-How to make certain dialogue options appear only when fulfilling criteria, for now, I'll go simple with the inventory stuff, so I just wanted some dialogue options to stay hidden until the player has a certain item in the inventory. So I guess a bool could work, when my character has that item, the bool is true and a new option appears in the conversation tree saying something like "give item" and that would move the story forward.
sorry that this is all very basic, I would really appreciate the help! thanks!
For doing the tutorials I learned to make a simple dialogue like in the quick start one, and I already adapted that to my game. But there are still some basic functions I can't quite find, so I would greatly appreciate if someone could guide me a little bit.
Right now, I just need these things:
-How to make a different dialogue for the second time you speak to an NPC. I already know how to "make it" but I can't make it so that one triggers after the first one... (EDIT: Ok I figured this one out using the "only once" and "Exclusive" options of the script, I guess there are better ways to do this... but for some reason these scripts aren't opening in Visual Studio, so I can't add an if or something to trigger them...)
-How to trigger other stuff to happen when certain dialogue appears, what I mean by this, is, for example, I plan to make a very simple inventory system, so if my character has a certain item, he can give it to an NPC and the story continues. So basically I would need the NPC to hand an item to the character after a certain dialogue, but I can't really find how to put that there... same for animations, I have some ready to make things like, when the NPC says "No" an animation of him shaking his head triggers, the same could work for dialogue.
-How to make certain dialogue options appear only when fulfilling criteria, for now, I'll go simple with the inventory stuff, so I just wanted some dialogue options to stay hidden until the player has a certain item in the inventory. So I guess a bool could work, when my character has that item, the bool is true and a new option appears in the conversation tree saying something like "give item" and that would move the story forward.
sorry that this is all very basic, I would really appreciate the help! thanks!
Re: Newbie needing help!
From what I've seen experimenting with this system so far you have a couple different options for your first question.
(If I'm not supposed to help others, apologies in advance.)
There are conditions inside of the Dialogue system so I would have a start and then have two different child nodes from the orange start node, the first for if it's the first time that you've talked to the NPC. The latter is for if it's the second or later. You'd want to make a variable called "timesTalkedTo" or something like that and at the end of the first conversation increment the "timesTalkedTo" variable, that way when you talk with the NPC the next time it'd go down the other branch.
To add a variable, go to the Variables tab and then click on the small plus in the lower right. You're able to make any sort of value you want. You could make it a counter (timesTalkedTo) or a boolean (isFirstTime) or however you want to name it or configure it.
That dialogue video goes more into conditions etc.
This video has a good sample of something similar to what you are wanting to do.
It checks to see how many babies have been rescued and bases conversations off of that. You can also have an option with the condition of (hasItemNeeded) or a check to see if the player has given item to hand it off using a similar model.
I would look at the tutorials for the PixelCrushers online as a good start. They are really helpful.
Another option is that you could have a separate "inventory" screen (standard for most point/click adventures) and have the user "drag" that item onto the NPC and when the two objects collide (use Unity Colliders) then have that spawn a new conversation (completely separate from the others). {{See Triggers video linked above for a suggestion on how to do that.}}
It really depends on what kind of UI you'd want to have and what goals you have in mind.
Good luck! Programming is awesome!
(If I'm not supposed to help others, apologies in advance.)
There are conditions inside of the Dialogue system so I would have a start and then have two different child nodes from the orange start node, the first for if it's the first time that you've talked to the NPC. The latter is for if it's the second or later. You'd want to make a variable called "timesTalkedTo" or something like that and at the end of the first conversation increment the "timesTalkedTo" variable, that way when you talk with the NPC the next time it'd go down the other branch.
To add a variable, go to the Variables tab and then click on the small plus in the lower right. You're able to make any sort of value you want. You could make it a counter (timesTalkedTo) or a boolean (isFirstTime) or however you want to name it or configure it.
That dialogue video goes more into conditions etc.
This video has a good sample of something similar to what you are wanting to do.
It checks to see how many babies have been rescued and bases conversations off of that. You can also have an option with the condition of (hasItemNeeded) or a check to see if the player has given item to hand it off using a similar model.
I would look at the tutorials for the PixelCrushers online as a good start. They are really helpful.
Another option is that you could have a separate "inventory" screen (standard for most point/click adventures) and have the user "drag" that item onto the NPC and when the two objects collide (use Unity Colliders) then have that spawn a new conversation (completely separate from the others). {{See Triggers video linked above for a suggestion on how to do that.}}
It really depends on what kind of UI you'd want to have and what goals you have in mind.
Good luck! Programming is awesome!
Re: Newbie needing help!
Thanks for jumping in, @MathBlade! I always appreciate the help, and the more perspectives the better. (And I totally forgot to link to those tutorials, so thank you again.)
Then create two branches in your conversation: the first branch for when the player talks to Bob for the first time, the second branch for when the player talks to Bob after that. Set the Conditions field of each branch to require a certain value of the "metBob" variable:
In the first branch, you'll want to set this variable true so the Dialogue System can remember that the player met Bob:
(To open those dropdown menus, click the "..." next to Conditions or Script. Remember to click the Apply button for each..)
Once you get the hang of that, you might be interested in some more advanced tricks:
AnimatorPlayWait() plays an animator state and leaves the subtitle visible until it's done playing. You'll probably want to link this state back to an idle state so the character stops shaking his head.
Working with other systems is a little more complicated, but the Dialogue System has features to make it easier. It will almost certainly require a little bit of scripting. The simplest way is to put a script on the NPC with two methods that accept
a string parameter. For example:
In the Sequence field, use the SendMessage() sequencer command to call these methods. For example:
The sequence above will play the "ExtendHand" animator state on Bob's Animator. And it will call the method TakeFromPlayer("Banana") on scripts on Bob.
If you need something more sophisticated, you can write a write a C# method and register it with Lua so you can use it in the Script field. For example, your Script field might look something like:
This could call a C# method that moves 12 bananas from the Player's inventory to Bob's inventory. You can find a starter script in the Templates/Scripts folder.
In this case you'll have to type that manually into the Conditions field because the "..." doesn't know about the PlayerHasItem() method ahead of time.
Thanks for using the Dialogue System! I think we can get this sorted out pretty quick.jeremycards wrote: ↑Sun Jul 15, 2018 6:36 pmHello, I'm a student of game development, and I'm currently finishing a 3 month Unity course and working on my final project, which I decided it to be a Monkey Island like adventure. My teacher suggested trying this system for it, so I'm trying to learn to use it, and it's really an amazing system! pretty much overkill for what I need right now. But since I'm still very new to programming, I'm really lost in what to do now, and can't quite piece together how to do what I need.
Define a Boolean variable in your dialogue database, for example called "metBob":jeremycards wrote: ↑Sun Jul 15, 2018 6:36 pm-How to make a different dialogue for the second time you speak to an NPC. I already know how to "make it" but I can't make it so that one triggers after the first one...
Then create two branches in your conversation: the first branch for when the player talks to Bob for the first time, the second branch for when the player talks to Bob after that. Set the Conditions field of each branch to require a certain value of the "metBob" variable:
In the first branch, you'll want to set this variable true so the Dialogue System can remember that the player met Bob:
(To open those dropdown menus, click the "..." next to Conditions or Script. Remember to click the Apply button for each..)
Once you get the hang of that, you might be interested in some more advanced tricks:
- If you're going to record a lot of information about Bob, you can record it in custom fields in Bob's actor definition (on the Actors tab). Or in more variables on the Variables tab. It's up to you. You can access actor fields as well as variables through the "..." dropdowns.
- You can link to other conversations. You could have a single starting conversation, a first time conversation, and a second time conversation. The starting conversation can link to the first time and second time conversation. To link to another conversation, inspect a node and in the Inspector's Link To: dropdown select "(Another Conversation)".
- You can group conversations into submenus by using forward slashes. For example: "Bob/Start", "Bob/First Time", "Bob/Second Time".
- Another way to do this is to add two Dialogue System Triggers, each with a Condition that checks the value of "metBob". This way you're checking the variable in the Dialogue System Trigger instead of the conversation. I prefer to keep all my logic contained inside the conversation, but this trick is something you might still want to be aware of.
The animation is easy. If you character has an Animator component, use one of the Animatorxxx() sequencer commands. For example, let's say your character has an animator state named "ShakeHeadNo". To play this state, set the Sequence field to:jeremycards wrote: ↑Sun Jul 15, 2018 6:36 pm-How to trigger other stuff to happen when certain dialogue appears, what I mean by this, is, for example, I plan to make a very simple inventory system, so if my character has a certain item, he can give it to an NPC and the story continues. So basically I would need the NPC to hand an item to the character after a certain dialogue, but I can't really find how to put that there... same for animations, I have some ready to make things like, when the NPC says "No" an animation of him shaking his head triggers, the same could work for dialogue.
AnimatorPlayWait() plays an animator state and leaves the subtitle visible until it's done playing. You'll probably want to link this state back to an idle state so the character stops shaking his head.
Working with other systems is a little more complicated, but the Dialogue System has features to make it easier. It will almost certainly require a little bit of scripting. The simplest way is to put a script on the NPC with two methods that accept
a string parameter. For example:
Code: Select all
public void TakeFromPlayer(string itemName)
{ // your code here
}
public void GiveToPlayer(string itemName)
{ // your code here
}
Code: Select all
AnimatorPlayWait(ExtendHand, Bob);
SendMessage(TakeFromPlayer, Banana, Bob)
If you need something more sophisticated, you can write a write a C# method and register it with Lua so you can use it in the Script field. For example, your Script field might look something like:
Code: Select all
MoveItems("Player", "Bob", "Banana", 12)
You can set variables (like "metBob" above) and/or register more C# methods with Lua. For example, say you register a C# method "PlayerHasItem(itemName)". You could set the Conditions field to:jeremycards wrote: ↑Sun Jul 15, 2018 6:36 pm-How to make certain dialogue options appear only when fulfilling criteria, for now, I'll go simple with the inventory stuff, so I just wanted some dialogue options to stay hidden until the player has a certain item in the inventory. So I guess a bool could work, when my character has that item, the bool is true and a new option appears in the conversation tree saying something like "give item" and that would move the story forward.
Code: Select all
PlayerHasItem("Banana") == true
-
- Posts: 7
- Joined: Sun Jul 15, 2018 6:24 pm
Re: Newbie needing help!
Wow, thank you very much! that's some stellar support.
With this, I was able to get the most important stuff out of the way, so I can at least finish the game. Thank you very much, I'll keep referring to this post and try to keep making improvements!
With this, I was able to get the most important stuff out of the way, so I can at least finish the game. Thank you very much, I'll keep referring to this post and try to keep making improvements!
Re: Newbie needing help!
Me too! Please keep programming.
-
- Posts: 7
- Joined: Sun Jul 15, 2018 6:24 pm
Re: Newbie needing help!
Ok, so I ran into a really huge bug that I can't put my finger into what the problem is, but I have a rough idea.
Right now I have a camera system that I made, in which when you exit an area, a camera turns off and another one turns on (Again trying to mimic those old adventure games with their fixed cameras). Also, I have a point and click movement system, similar to the one included with the dialogue system, but this one I had from before I implemented it. What's happening now, is that when I go to an NPC in the second area, first, the "press space to interact" does not appear (it does with characters in the first area), and if I do press space, the conversation does start... but for some reason the camera flies off to who know's where and I'm left staring to the skybox... so yeah... its a pretty complicated problem.
My best guess is that it has something to do with the camera change, maybe something in the code is set to the main camera to shoot some raycast or something... and it's not changing along with my camera system, but I have no idea where to look for that... any ideas to what could be causing this?
Right now I have a camera system that I made, in which when you exit an area, a camera turns off and another one turns on (Again trying to mimic those old adventure games with their fixed cameras). Also, I have a point and click movement system, similar to the one included with the dialogue system, but this one I had from before I implemented it. What's happening now, is that when I go to an NPC in the second area, first, the "press space to interact" does not appear (it does with characters in the first area), and if I do press space, the conversation does start... but for some reason the camera flies off to who know's where and I'm left staring to the skybox... so yeah... its a pretty complicated problem.
My best guess is that it has something to do with the camera change, maybe something in the code is set to the main camera to shoot some raycast or something... and it's not changing along with my camera system, but I have no idea where to look for that... any ideas to what could be causing this?
Re: Newbie needing help!
Hi,
Are there any errors or warnings in the Console window?
Are you using a Selector, a Proximity Selector, or neither?
Have you assigned anything to the Dialogue Manager's Camera & Cutscene Settings > Sequencer Camera field?
In your conversation, or in the Dialogue Manager's Default Sequence field, are you using any Camera() sequencer commands?
Are there any errors or warnings in the Console window?
Are you using a Selector, a Proximity Selector, or neither?
Have you assigned anything to the Dialogue Manager's Camera & Cutscene Settings > Sequencer Camera field?
In your conversation, or in the Dialogue Manager's Default Sequence field, are you using any Camera() sequencer commands?
-
- Posts: 7
- Joined: Sun Jul 15, 2018 6:24 pm
Re: Newbie needing help!
The only errors I'm getting in the console are about having many audio listeners.Tony Li wrote: ↑Mon Jul 16, 2018 9:04 am Hi,
Are there any errors or warnings in the Console window?
Are you using a Selector, a Proximity Selector, or neither?
Have you assigned anything to the Dialogue Manager's Camera & Cutscene Settings > Sequencer Camera field?
In your conversation, or in the Dialogue Manager's Default Sequence field, are you using any Camera() sequencer commands?
I'm using a Proximity Selector.
as for the Cutscene settings, I left all as default, here's a screencap just in case.
I'm guessing it's some issue with the main camera, looking into that now...
EDIT: FIXED
Alright, it was a problem with the Main Camera setting, the other cameras weren't tagged as main cameras, so even if I tried setting them as main cameras with code, it didn't quite work, but tagging them all did. Thanks for the help!
- Attachments
-
- 1.png (36.73 KiB) Viewed 1525 times
Re: Newbie needing help!
Sorry I didn't provide much help on that one, but I'm glad you were able to find the problem and fix it.