Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Babilinski · Jul 06, 2011 at 04:53 AM · c#systemdialoguequest

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 = ;}
 
         }
         
 }
Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image testure · Jul 06, 2011 at 05:32 AM 0
Share

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.

avatar image Babilinski · Jul 06, 2011 at 04:43 PM 0
Share

I need to calculate the distance so that once you get near the dad you can speek to him

avatar image testure · Jul 06, 2011 at 04:53 PM 0
Share

http://tinyurl.com/5w9yyo9

avatar image Babilinski · Jul 06, 2011 at 05:13 PM 0
Share

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

avatar image · Jul 06, 2011 at 05:36 PM 0
Share
I added tags to format your code, but it's still quite a bit of a mess. Though @testure wasn't as polite as they could've been, you really should have been able to solve this one with that exact google search: "unity calculate distance"

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by McGivvern · Jun 19, 2012 at 05:48 PM

Why not use a Triggered Collider and attach a script to it?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Ludiares.du · Jul 06, 2011 at 05:28 PM

Try using:

 if(Vector3.Distance(player, dad) < 3)
 {
 //talk
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image · Jul 06, 2011 at 05:38 PM 0
Share
To be clear for @Babilinski - this is pseudo code. You'll need to substitute the actual positions of the 'player' and 'dad'. You'd also be best off using the sqr distance (as it's more efficient), and checking for `

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

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

How do you list all the days of the current month? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges