Page 1 of 1

Problems with my project 2D

Posted: Sun Mar 26, 2023 9:38 pm
by lupiyo
Hello,

I have few questions:
  • How do you usually deal with additives maps on unity, with the dialog?
    I Can't move the player to the npc inspector because they are on separated scenes.
  • I'm try to use it on my smartphone, it is 2D, and i'm following the youtube tutorial OnUse(). But when i click on NPC (with the mouse fire2 on pc for debug) nothing happens, I didn't change the button yet. Am I missing sometinhg?
  • On unity, I'm using an asset that saves any variable of any kid using keyword-value, can I use it with the quest system?
Thanks!

Re: Problems with my project 2D

Posted: Mon Mar 27, 2023 9:38 am
by Tony Li
Hello,
lupiyo wrote: Sun Mar 26, 2023 9:38 pm
  • How do you usually deal with additives maps on unity, with the dialog? I Can't move the player to the npc inspector because they are on separated scenes.
You don't need to assign it. Add a Dialogue Actor component to the player, and set its Actor dropdown to the Player actor. Then leave the Dialogue System Trigger's Conversation Actor field blank. If the conversation's primary actor is set to the Player Actor, it will find the correct GameObject via the Dialogue Actor component.

For more info, please see Character GameObject Assignments.
lupiyo wrote: Sun Mar 26, 2023 9:38 pm
  • I'm try to use it on my smartphone, it is 2D, and i'm following the youtube tutorial OnUse(). But when i click on NPC (with the mouse fire2 on pc for debug) nothing happens, I didn't change the button yet. Am I missing sometinhg?
If you're using the Selector component (with Select At set to Mouse Position) and you don't see the selector UI at the top of the screen when you hover over the NPC, make sure you've enabled 2D support. In the Dialogue System's Welcome window (Tools > Pixel Crushers > Dialogue System > Welcome Window), tick the USE_PHYSICS2D checkbox. If you still don't see it, make sure the NPC has a collider and that it's on a layer in the Selector's Layer Mask, and that it has a Usable component.

If you do see the selector UI but nothing happens when you press mouse Fire2, make sure the NPC's Dialogue System Trigger is set to OnUse. If it's set to OnUse but nothing happens, temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. Then try again. This should log additional info to the Console window that may help you determine what's going on.
lupiyo wrote: Sun Mar 26, 2023 9:38 pm
  • On unity, I'm using an asset that saves any variable of any kid using keyword-value, can I use it with the quest system?
Yes. You can write a simple C# method that returns the variable value by keyword. Then make that method accessible to the Dialogue System's Lua so you can use it in Conditions and Script fields. (Tutorial)

Re: Problems with my project 2D

Posted: Tue Mar 28, 2023 9:59 pm
by lupiyo
If you're using the Selector component (with Select At set to Mouse Position) and you don't see the selector UI at the top of the screen when you hover over the NPC, make sure you've enabled 2D support.
In case of a android game, if I hold the touch it is the same as mouse over? My game is for mobile. My trigger now is when i get inside the collider, but it is not the ideal, i want to touch the npc on smartphone screen to talk with him, is it possible?

Thanks!

Re: Problems with my project 2D

Posted: Tue Mar 28, 2023 11:01 pm
by Tony Li
It depends on how you want interaction to work.

If you want a single tap to start a conversation, you don't need a Selector or Proximity Selector. You can add a script with an OnMouseDown() method that calls the Dialogue System Trigger's OnUse:

UseOnMouseDown.cs

Code: Select all

using UnityEngine;
public class UseOnMouseDown : MonoBehaviour
{
    void OnMouseDown() // Assumes GameObject has a collider.
    {
        BroadcastMessage("OnUse");
    }
}

Re: Problems with my project 2D

Posted: Wed Mar 29, 2023 9:26 pm
by lupiyo
Hello, thanks for the tip!

I wrote that but now i get an error:

Code: Select all

Failed to call function OnUse of class DialogueSystemTrigger
Calling function OnUse with no parameters but the function requires 1.
UnityEngine.Component:BroadcastMessage (string)
NPC:OnMouseDown () (at Assets/Scripts/NPC/NPC.cs:9)
UnityEngine.SendMouseEvents:DoSendMouseEvents (int)
I coded on my npc class, which has the Dialog System Trigger, Trigger: OnUse


Code: Select all

public class NPC : MonoBehaviour
{
    void OnMouseDown() // Assumes GameObject has a collider.
    {
        BroadcastMessage("OnUse");
    }
}
My player has 2 components Selector, and Selector use Standard UI Elements.

It was working with the aproximaty, but with the click I doesn't. Can you help me, please?
Thanks!!! =)

Re: Problems with my project 2D

Posted: Wed Mar 29, 2023 9:38 pm
by lupiyo
I just read on documentation class called Npc, which gives gold, etc. Is there a problem creating another class called NPC? Can I use the same, in this case?

I was looking for how to reward a player after quest. Can i create a function, on my own script and registrate it on the lua? and call it in the last dialog box on script?

Thanks again!

Re: Problems with my project 2D

Posted: Wed Mar 29, 2023 9:47 pm
by Tony Li
Hi,

Try changing the OnMouseDown() method to this:

Code: Select all

void OnMouseDown() // Assumes GameObject has a collider.
{
    var dialogueSystemTrigger = GetComponent<PixelCrushers.DialogueSystem.DialogueSystemTrigger>();
    if (dialogueSystemTrigger != null) dialogueSystemTrigger.OnUse();
}

> I just read on documentation class called Npc, which gives gold, etc. Is there a problem creating another class called NPC? Can I use the same, in this case?

The Dialogue System doesn't have a class called Npc. (The uMMORPG integration does extend uMMORPG's Npc class if that's what you're looking at.) You can create your own NPC class.


> I was looking for how to reward a player after quest. Can i create a function, on my own script and registrate it on the lua? and call it in the last dialog box on script?

Yes. Video Tutorial