Hello,
Currently all Quest interactions are started by colliding with the NPC trigger collider. I want to only start the process when I stand close to the NPC (perhaps when colliding) and the.hit for example space key on the keyboard.
Start quest dialog with space key
Re: Start quest dialog with space key
Hi,
You can use your preferred interaction system/script for that. Your interaction system/script just needs to call the QuestGiver's StartDialogueWithPlayer() method.
For example, if you're using the Dialogue System for Unity, it has a "Proximity Selector" interaction system. Using this system, you can put a "Usable" component on the NPC and configure its OnUse() method to call QuestGiver.StartDialogueWithPlayer().
If you're using any other interaction system, you'd set it up similarly.
You can use your preferred interaction system/script for that. Your interaction system/script just needs to call the QuestGiver's StartDialogueWithPlayer() method.
For example, if you're using the Dialogue System for Unity, it has a "Proximity Selector" interaction system. Using this system, you can put a "Usable" component on the NPC and configure its OnUse() method to call QuestGiver.StartDialogueWithPlayer().
If you're using any other interaction system, you'd set it up similarly.
-
- Posts: 39
- Joined: Sat Apr 20, 2024 7:03 pm
Re: Start quest dialog with space key
Thank you!
If anyone wonders how I made it work is that I added this script to the player:
If anyone wonders how I made it work is that I added this script to the player:
Code: Select all
using UnityEngine;
using PixelCrushers.QuestMachine;
public class CharacterQuestGiverActivation : MonoBehaviour
{
private QuestGiver currentQuestGiver;
private void Update()
{
if (currentQuestGiver != null && (Input.GetKeyDown(KeyCode.E)))
{
currentQuestGiver.StartDialogueWithPlayer();
}
}
private void OnTriggerEnter(Collider other)
{
QuestGiver questGiver = other.GetComponent<QuestGiver>();
if (questGiver != null)
{
currentQuestGiver = questGiver;
}
}
private void OnTriggerExit(Collider other)
{
if (other.GetComponent<QuestGiver>() != null)
{
currentQuestGiver = null;
}
}
}
Re: Start quest dialog with space key
Thanks for sharing!