- Home /
Creating a Quest system
Okay Well I now am making a quest / dialogue system and I'm stuck on finishing the quest exp "go talk to your father" "STUCK PART"
I'm using C#
using UnityEngine;
using System.Collections;
public class Speek : MonoBehaviour {
// Use this for initialization
public void Start ()
{
CurrentMenu = MainMenu;
DisplayMenu = false;
}
// Update is called once per frame
public void Update()
{
if (Input.GetMouseButtonDown(1))
DisplayMenu = !DisplayMenu;
}
public void OnGUI()
{
if (DisplayMenu)
CurrentMenu();
}
private delegate void MenuDelegate();
private MenuDelegate CurrentMenu;
private bool DisplayMenu;
public string name;
public string QuestPage1;
public string QuestPage2;
private bool Quest = false;
public GameObject target;
//
// Main menu
//
private void MainMenu ()
{
Rect MainMenuRect = new Rect((Screen.width - 280) / 2, (Screen.height - 100) / 1.03f, 630, 108);
GUI.BeginGroup(MainMenuRect);
GUI.Box(new Rect(10, 10, MainMenuRect.width, MainMenuRect.height), name );
GUI.Label(new Rect(25, 25, 540, 80), QuestPage1 );
if (GUI.Button(new Rect(540, 80, 80, 20), "Next"))
{
CurrentMenu = Next;
}
}
private void Next(){
Rect OptionsRect = new Rect((Screen.width - 280) / 2, (Screen.height - 100) / 1.03f, 630, 108);
GUI.BeginGroup(OptionsRect);
GUI.Box(new Rect(10,10,OptionsRect.width,OptionsRect.height), name );
GUI.Label(new Rect(25, 25, 540, 80), QuestPage2 );
if (GUI.Button(new Rect(15, 80, 80, 20), "Back"))
{
CurrentMenu = MainMenu;
}
if (GUI.Button(new Rect(540, 80, 80, 20), "Okay"))
{
DisplayMenu = false;
Quest = true;
}
}
private void Quest () {
if (Input.GetKeyDown("a")) {
QuestPart1 = ;}
}
}
oh, that's easy. you just need to do that one thing and you'll be unstuck. all you have to do now is figure out what it is and you're set.
I need to calculate the distance so that once you get near the dad you can speek to him
no I cant find it. I need the quest to be done at a specific rang . A$$anonymous$$A I dont want people to be able to talk to Dad if they are not near him
Answer by McGivvern · Jun 19, 2012 at 05:48 PM
Why not use a Triggered Collider and attach a script to it?
Answer by Ludiares.du · Jul 06, 2011 at 05:28 PM
Try using:
if(Vector3.Distance(player, dad) < 3)
{
//talk
}
Your answer
Follow this Question
Related Questions
Quests/Dialogue (C#) 0 Answers
How to Move player by itself to a positions when talking to an NPC? 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers