Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Klown · Jul 18, 2013 at 04:57 PM · key pressed

Equip in-game map item

Currently I am working on a game using the Oculus rift and we need a map system, so I am building a physical map the player can pull out and look at in-game.

I'm having a great deal of trouble scripting a way to pull out the map and put it away with the same key stroke. I can't seem to get the code right in C#. :[

Any help is appreciated.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by bubzy · Jul 18, 2013 at 05:38 PM

 using UnityEngine;
 using System.Collections;
 
 public class mapToggle : MonoBehaviour {
 
     // Use this for initialization
     bool mapOut = false;
     
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
     if(Input.GetKeyDown(KeyCode.M))
         {
             toggleMap();
         }
         
     }
     
     void toggleMap()
     {
         mapOut = !mapOut;
     }
     
     void OnGUI()
     {
         if(mapOut)
         {
             GUI.Label(new Rect(0,0,200,100),"MAP IS OUT!");
         }
         else
         {
             GUI.Label(new Rect(0,0,200,100),"MAP IS NOT OUT!");
         }
         
     }
 
 }

Updated in actual working code. please try though to learn this stuff yourself, maybe find some basic c# tutorials, you will NEVER finish a project by asking here everytime you get stuck. good luck with your project :)

Comment
Add comment · Show 5 · 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 Klown · Jul 24, 2013 at 08:16 PM 0
Share

I understand that this is a 'working' code, but this is not solving my issue. The only thing that is happening is the broadcast of $$anonymous$$AP IS OUT or $$anonymous$$AP IS NOT OUT.

I want to pull up a in-game psychical map to look at and put away.

avatar image bubzy · Jul 29, 2013 at 09:01 AM 0
Share

i think you need to learn some more coding then, this DOES EXACTLY what you need, but you have to code the map in and out yourself, its a framework to build on. if you cannot do this yourself, then perhaps you should start with a more basic project and work your way up. I mean, I don't have your resources, your model files, how the map looks, what happens when the map is up, I don't have the names of the other objects in your scene or how to interact with them. there is a lot to consider, and please don't ask other people to write your game for you, aside from anything else (and that no one would do it), you totally lose any satisfaction of completing your own project. my answer is still correct though.

avatar image Klown · Aug 01, 2013 at 01:45 PM 0
Share

I ended up fixing it and making it work, though I did change the coding you gave me.

No reason to be rude, I wasn't asking you to write my $$anonymous$$ms game for me. Just a simple structure to go by so I could learn more.

Code for reference:

 using UnityEngine;
 using System.Collections;
  
 public class mapToggle : $$anonymous$$onoBehaviour {
  
     // Use this for initialization
     bool mapOut = false;
  
     void Start () {
  
     }
  
     // Update is called once per frame
     void Update () {
     if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.$$anonymous$$))
        {
             // toggle visibility:
         renderer.enabled = !renderer.enabled;
         }
     }
     
 }
avatar image bubzy · Aug 01, 2013 at 09:20 PM 0
Share

wasn't trying to be rude mate :) sorry if it came across that way.

by the way, that Boolean value (mapOut) wont be required unless you are using it in another point of your code.

avatar image Klown · Aug 01, 2013 at 09:24 PM 0
Share

Not a problem, I appreciate your help :)

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

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

is it possible to make the player to transform into a differet object? 0 Answers

spawn object on keypress c# 2 Answers

Make a rigidbody sphere stop while moving fast 2 Answers

Grapple gun help 1 Answer

Switch from GUI button to toggle key 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