Page 1 of 1

Top Down 2D JRPG game conversation trigger

Posted: Sat Jun 26, 2021 11:16 am
by Tony Chou
I am working on a top down JRPG project.
I would like to implement the following features.
1. When the player is close to the NPC, press KeyCode.Z to start a conversation
2. User press KeyCode.Z to continue conversation.
3. To avoid repeated conversations caused by users pressing KeyCode.Z by mistake. After conversation end, delay 0.5 second to let NPC can be trigger again.

Re: Top Down 2D JRPG game conversation trigger

Posted: Sat Jun 26, 2021 11:38 am
by Tony Li
Hi,
Tony Chou wrote: Sat Jun 26, 2021 11:16 am1. When the player is close to the NPC, press KeyCode.Z to start a conversation
Use a Proximity Selector component. (See Interaction Tutorial.) If you don't want to use a Proximity Selector, you can use your own interaction system. Just configure it to call the NPC's Dialogue System Trigger > OnUse method.
Tony Chou wrote: Sat Jun 26, 2021 11:16 am2. User press KeyCode.Z to continue conversation.
Add a UI Button Key Trigger component to your dialogue UI's continue button. Set its Key to Z. (See Dialogue UI Tutorial for info on customizing dialogue UIs.)

continueZ.png
continueZ.png (57.18 KiB) Viewed 338 times
Tony Chou wrote: Sat Jun 26, 2021 11:16 am3. To avoid repeated conversations caused by users pressing KeyCode.Z by mistake. After conversation end, delay 0.5 second to let NPC can be trigger again.
Configure the NPC like this:

usableTimedDelay.png
usableTimedDelay.png (69.96 KiB) Viewed 338 times

When the Dialogue System Trigger starts, it will start the conversation and disable the NPC's Usable component. When the conversation ends, it will start a timer that re-enables the Usable component after 0.5 seconds.