Gather Quest

Announcements, support questions, and discussion for the Dialogue System.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Gather Quest

Post by supadupa64 »

I set up everything perfectly to gather items, but I just can't figure out how to gather the item. The dialogue is set up, but when I try to interact with the object I can't get it to destroy and be added to the quest.
scrolls_gatheringquest.jpg
scrolls_gatheringquest.jpg (223.05 KiB) Viewed 1779 times
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Gather Quest

Post by Tony Li »

Add this script to your object:

DestroyOnUse.cs

Code: Select all

using UnityEngine;

public class DestroyOnUse : MonoBehaviour
{

    public PixelCrushers.DialogueSystem.Condition condition;
    
    void OnUse(Transform user)
    {
        if (condition.IsTrue(user)) Destroy(this.gameObject);
    }
} 
Also add a Persistent Destructible component. This will make saved games record the fact it was destroyed. When you load the game, it will make sure the object is still destroyed.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Gather Quest

Post by supadupa64 »

Awesome! Thank you!

There's just one thing. Everything works except the quest tracker doesn't keep track of the number when I gather. I can collect one, but after that it doesn't move. Although, if I collect a different object first it goes to one, then to two if I collect the first one I created. But then back to one if I collect another object! lol? It's weird. I've tested it a bunch and can't seem to figure it out.

Here's a shot, maybe this can help.
scrolls_quest.jpg
scrolls_quest.jpg (246.83 KiB) Viewed 1774 times
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Gather Quest

Post by supadupa64 »

Also, in the tutorial there was one little problem I saw when I played it and with my own quest. What's to stop the player from interacting with the quest object before the player gets the quest? o.O There has to be some kind of activate object script because we can't have the player collecting scrolls without getting the quest... And I shot all your enemies in your tutorial before I got the quest, then when I got it, uh oh, I can't do the quest any more. Ya know?
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Gather Quest

Post by Tony Li »

Hi,
supadupa64 wrote:Everything works except the quest tracker doesn't keep track of the number when I gather. I can collect one, but after that it doesn't move. Although, if I collect a different object first it goes to one, then to two if I collect the first one I created. But then back to one if I collect another object! lol? It's weird. I've tested it a bunch and can't seem to figure it out.
Check your Increment On Destroy components. If the Max value is set to 1, then it will cap "numscrollsfound" at 1, even if the starting value is higher.
supadupa64 wrote:Also, in the tutorial there was one little problem I saw when I played it and with my own quest. What's to stop the player from interacting with the quest object before the player gets the quest? o.O There has to be some kind of activate object script because we can't have the player collecting scrolls without getting the quest... And I shot all your enemies in your tutorial before I got the quest, then when I got it, uh oh, I can't do the quest any more. Ya know?
This is partly technical and partly a design choice.

What should happen when the player interacts with a scroll before accepting the quest? Here are some design choices and the technical details of how to implement them:

1. Keep the scrolls hidden until the player accepts the quest:
  • Make all the scrolls children of an empty GameObject, for example called "Quest Scrolls".
  • Make this empty GameObject a child of another GameObject, for example called "Quest Objects".
  • Deactivate "Quest Scrolls".
  • When the player accepts the quest, use the SetActive() sequencer command to activate "Quest Scrolls":

    Code: Select all

    SetActive(Quest Scrolls)
  • Add a Persistent Active Data component to "Quest Objects". Configure it to activate "Quest Scrolls" only if the quest is active. This is for saved games.
2. Allow the player to interact with scrolls, but show a "not yet" message if the player hasn't accepted the quest:
  • Use the updated version of DestroyOnUse that I just updated in my previous post. In the Condition section, add a quest condition that the quest must be active.
  • Add an Alert Trigger with a message like "You can't pick that up yet." In the Condition section, add a quest condition that the quest must be unassigned.
3. Allow the player to collect scrolls anyway to get a head start before accepting the quest:
  • Let the player collect scrolls even if he hasn't accepted the quest.
  • In your quest conversation, check the value of "numscrollsfound" before offering the quest to the player. If the player has already found all the scrolls, jump to the part of the conversation where the player turns in the scrolls to complete the quest.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Gather Quest

Post by supadupa64 »

Thank you again! I got scrolls to appear when I accept the quest and it works great.

It's still not keeping track of the scroll count. Something is obviously messed up. I feel like the problem is with the scroll not communicating the count correctly. Also, sometimes when I go back to the quest giver I can't interact with him... Hmmmm..
destroy_scrolls.jpg
destroy_scrolls.jpg (52.43 KiB) Viewed 1766 times
https://www.youtube.com/watch?v=5ZaWlo7wiX0
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Gather Quest

Post by Tony Li »

Hi,

What are you using to target the NPC, the Dialogue System's Selector? If so, it's possible that your player character model is blocking the raycast from the camera to the NPC at certain angles. If this is what's happening, you can consider changing the player's Layer to Ignore Raycast, but keep in mind that this will cause it to be ignored from other raycasts, too. I don't know if that impacts any other parts of your game or not.

Another alternative: You could switch to ProximitySelector and put it on a child GameObject that has a trigger collider in front of the player.

Are all of your scrolls set up exactly the same? Do they all have Increment On Destroy components? Is the Max value 10 on all of them?
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Gather Quest

Post by supadupa64 »

Yes, I'm using selector dialogue script to select object and things. I press "e" for use. If I go around collecting scrolls the number randomly moves from 1 to 2 and back to 1, but never higher than 2. I changed the raycast in the selector options script and it didn't work. I feel like it may be a problem with how I set up the quest maybe. If I accept this quest, pick up one scroll, then go accept another quest from another NPC, it changes the scroll count to TRUE. No idea why it does that.

Every scroll is set up like this:
scroll_setup.jpg
scroll_setup.jpg (177.26 KiB) Viewed 1759 times
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Gather Quest

Post by Tony Li »

It's the Persistent Destructible. Give each scroll a unique Persistent Destructible > Variable Name that's not numscrollsfound -- for example, Scroll01, Scroll02, Scroll03, etc.
User avatar
supadupa64
Posts: 200
Joined: Sun Mar 06, 2016 9:40 pm
Contact:

Re: Gather Quest

Post by supadupa64 »

I mean, wow, it worked, finally! I'm speechless, lol. THANK YOU!
Post Reply