• 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 mysticneji · May 14, 2013 at 01:44 AM · c#tutorialingame

How would I make an ingame tutorial??

Hello, I'm trying to make a tutorial in game. One that explains how to work the basics of the game. I want it to stop the game when the character reaches a certain point and have some text come up telling what to do and then start again when the player hits a button on the keyboard. Right now I'm trying to use a case switch but I'm not sure if that will work. Here's what I have so far:

 using UnityEngine;
 using System.Collections;
 
 public class Tutorial : MonoBehaviour 
 {
     
     int tut_state;
     
     const int state_1 = 1;
     const int state_2 = 2;
     const int state_3 = 3;
     const int state_4 = 4;
     const int state_5 = 5;
     const int state_6 = 6;
     const int state_7 = 7;
     const int state_8 = 8;
     
     string display_text;
     
     public string welcome;
     public string moving;
     public string pickUps;
     public string shooting;
     public string doors;
     public string floating;
     public string state7;
     public string state8;
     
     
     private bool beginTut = false;
     private bool endTut = false
         ;
     
     bool showGUI = false;
     
     Rect display_box = new Rect(0,0, 200,200);
     // Use this for initialization
     void Start () 
     {
 
     }
     
     void OnTriggerEnter()
     {
         if(!endTut)
         {
             
             beginTut = true;
             showGUI = true;
             
         }
         
     }
     
     // Update is called once per frame
     void Update () 
     {
         
         if(!endTut && beginTut)
         {
             Time.timeScale = 0;
         }
         if(endTut)
         {
             Time.timeScale = 1;
             showGUI = false;
         }
     
     }
     
     void OnGUI()
     {
         switch(tut_state)
         {
         case state_1:
             display_text = welcome;
             break;
         case state_2:
             display_text = moving;
             break;
         case state_3:
             display_text = pickUps;
             break;
         case state_4:
             display_text = shooting;
             break;
         case state_5:
             display_text = doors;
             break;
         case state_6:
             display_text = floating;
             break;
         case state_7:
             display_text = state7;
             break;
         case state_8:
             display_text = state8;
             break;                
         }
             
         GUI.Label(display_box, display_text);
         
         if(Input.GetKeyDown(KeyCode.B))
         {
             tut_state++;
         }
     }
 }

Any help would be appreciated! Thanks!!

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by sparkzbarca · May 14, 2013 at 02:09 AM

for the when a player reaches a certain point what your going to want to do is.

create an empty game object.

Add a box collider.

check the is trigger checkmark in the properties.

now your collider is a trigger box. whenever anything enters the bounds it will send a

OnTriggerEnter call and give you the collider that hit it. so

attach a script to this empty trigger object

 OnTriggerEnter(collider Player)
 {
 //first confirm it is in fact the player
 if(Player.tag == "player") 
 {
 //display text box
 }
 }

there you go they got to a point and text popped up

your switch method is an acceptable way to change up the text displayed I don't see anything wrong with it. (it's not how i'd do it, but everyone has there own methods and your method is perfectly good)

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 mysticneji · May 14, 2013 at 04:45 PM

That helps and while I don't get any errors it won't display any of the text when I walk into the box collider.

     void OnTriggerEnter(Collider other)
     {
         
         if(other.gameObject.tag == "Player")
         {
             GUI.Label(display_box, display_text);
         }
         
         switch(other.gameObject.tag)
         {
         case "Tutorial1":
             display_text = walking;
             break;
         case "Tutorial2":
             display_text = shooting;
             break;
         case "Tutorial3":
             display_text = pickUps;
             break;
         case "Tutorial4":
             display_text = doors;
             break;
         case "Tutorial5":
             display_text = floating;
             break;
         /*case state_6:
             display_text = state6;
             break;
         case state_7:
             display_text = state7;
             break;
         case state_8:
             display_text = state8;
             break;*/                
         }
         Destroy(gameObject);
         
     }

Putting the == "Player in the switch statement gives me errors saying that I can't convert a string to a bool so I don't have it in there. I know I'm doing probably a couple things wrong but can't figure out what.

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 thendricks · May 14, 2013 at 07:27 PM

You could use a video if your a unity pro user or you could have images and gui text telling you what to do. If your desperate to use a video and your an indie user try getting a indie video asset converter thing.

Video unity lite stuff

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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

17 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How do I reassign a variable? 1 Answer

Raycast chase player, avoid walls.. raycast detailed C# tutorial? 0 Answers

Making a Tutorial in th emiddle of screen and more efficiant 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