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 craig101 · Mar 10, 2013 at 09:18 AM · collisionhud

Creating and removing HUDs on Collision

I want to be able to create HUD's on a first person controller collision with objects for example when the user starts they have to find a list of things to fine, a list of those objects appear on the side as HUD's and when the user finds the item the HUD for that object is removed as it no longer needs to be found.

I also want a map hug to appear in a top corner.

I'm coding in Javascript if that helps :)

This is my first project with Unity3D ever, so any help would be awesome, thank you :)

Comment
Add comment · Show 4
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 Seth-Bergman · Mar 10, 2013 at 09:38 AM 0
Share

one thing at a time... start with the script reference, it has all the answers:

http://docs.unity3d.com/Documentation/Components/GUIScriptingGuide.html

http://docs.unity3d.com/Documentation/Components/gui-Basics.html

avatar image craig101 · Mar 10, 2013 at 10:08 AM 0
Share

I don't understand how that helps, thats creating buttons when i went text, and none of them deal with appearing from a collision as far as i can see

avatar image Eeppi · Mar 10, 2013 at 10:31 AM 0
Share

I'm typing this with my phone so I can't give detailed answer, but try http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$onoBehaviour.OnCollisionEnter.html

avatar image craig101 · Mar 10, 2013 at 10:34 AM 0
Share

I'm sorry but i don't understand how that helps either.

I have a ontrigger event for when a collision takes place and the item is removed, if that helps

1 Reply

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

Answer by Seth-Bergman · Mar 10, 2013 at 10:39 AM

http://docs.unity3d.com/Documentation/Components/GUIScriptingGuide.html

http://docs.unity3d.com/Documentation/Components/gui-Basics.html

The first link has links to EVERY GUI control... not just buttons!!! take the time to READ IT, and you may BEGIN to understand

here's how to do what you ask...

(if this helps you, please be sure and click the check mark to accept my answer)

first, we can create a var to decide whether to show our HUD:

  var showSampleHud : boolean = false;

a boolean is either true or false

now we can set up our GUI:

  function OnGUI(){

  if(showSampleHud){
  GUI.Box(Rect...etc
  GUI.Label(Rect(Screen.width...etc
  GUI.SEE SCRIPTING GUIDE!!!...etc
  }

  }

now all that's left is the collision:

  function OnCollisionEnter(other : Collider){
  if(other.tag == "showme")
  showSampleHud = true;
  }


of course, your collision will require the proper setup to register, i.e. a collider or character controller on each object, and at least one rigidbody for starters..

Here's the whole script:

  var showSampleHud : boolean = false;

 function OnGUI(){

  if(showSampleHud){
     GUI.Box(Rect...etc
     GUI.Label(Rect(Screen.width...etc
     GUI.SEE SCRIPTING GUIDE!!!...etc
     }
  }
  function OnCollisionEnter(other : Collider){
  if(other.tag == "showme")
  showSampleHud = true;
  }

hope this helps!

Comment
Add comment · Show 15 · 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 craig101 · Mar 10, 2013 at 10:52 AM 0
Share

I get a error saying "The name 'collider' does not denote a valid type'

avatar image Seth-Bergman · Mar 10, 2013 at 10:53 AM 0
Share

oops it needs to be capital, i'll fix it..

fixed.. but keep in $$anonymous$$d collisions can be tricky..

of course, you also need to remember to make sure the tag is set up on your object

and do NOT set to isTrigger

and at least one of the objects needs a rigidbody (maybe both..)

the collision matrix at this link (near the bottom) can be helpful:

http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html

avatar image craig101 · Mar 10, 2013 at 10:56 AM 0
Share

The only problem is that it starts on and then on the collision goes off, i want it to start off, then come on, after a collision, but then again removed when it collides with the correct item

avatar image Seth-Bergman · Mar 10, 2013 at 11:05 AM 0
Share

you should have no problem using this example to figure that out!

just switch "true" and "false" as needed!

for different reactions, use different tags!

 if(other.tag == "showme")
 showHUD = true;
 if(other.tag == "target")
 showHUD = false;

if this is too much to grasp, you should take a step back and learn the basics of program$$anonymous$$g FIRST, me writing your game for you doesn't help you!

avatar image craig101 · Mar 10, 2013 at 11:13 AM 0
Share

switching true and false on that is making no difference at all.

I can do program$$anonymous$$g, i can do flash, i'm just struggling to get this, seems overly complex when it doesn't need to be.

Show more comments

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

12 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

Related Questions

How to move an object over a distance in a direction? 2 Answers

How to approximate this surface with primitives? 1 Answer

Pickaxe Collision Problems 1 Answer

My weapon takes damage. help... 1 Answer

How to get A Camera Collision? 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