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 sarim987 · Mar 24, 2014 at 10:48 PM · colliderdistanceguitexture

"Show GUITexture within distance" issue

Hi, i was wondering how to do this.... I want to make it so when a car goes in a building. It shows a guitexture. I was thinking about doing it where, when the car is near a gameobject in the builing, enable a button. i also tried doing where you have a collider and the car will show the texture when it is touching the collider. this way didnt work

im going to stick to the first.

When i run this script. it only works for one building. when i duplicate it, it doesn't work. Itll only work for one, no matter how many i have. Can someone please help?

 #pragma strict
 
 var RepairCubeTeller : Transform;
 
 var guitexture : GUITexture;
 
  function Update () {
      var dist : float = Vector3.Distance(RepairCubeTeller.position, transform.position);
                          
      if(dist<10)
      {
         guitexture.enabled = true;
         
      }
    
  else
    {
         guitexture.enabled = false;
         
    }
 }
 
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 robertbu · Mar 25, 2014 at 05:01 AM 0
Share

Do you have multiple cars? Is the 'RepairCubeTeller' one of your cars? I assume you initialize each script with a different guiTexture?

avatar image sarim987 · Mar 25, 2014 at 02:18 PM 0
Share

Yes. I have 4 cars. The repaircubeteller is a game object attached to the main camera. The main camera switches between cars. The script is attached to a game object inside the buildings. The same script is attached to all of the game objects inside the buildings.

avatar image robertbu · Mar 25, 2014 at 02:56 PM 0
Share

The script looks fine, so I'm trying to understand what you are seeing. Does it not fire for the other positions, or is the GUITexture is the wrong place, or...? Do you have just a single GUITexture object or do you have one for each place this script is attached? You have initialize the 'guitexture' variable in the Inspector?

avatar image sarim987 · Mar 25, 2014 at 08:39 PM 0
Share

Ya it's weird, I made one building with the script and it worked. But as soon as I duplicate it, suppose it did five. It only works for one of those five buildings. I'm really confused. Thanks for the help.

avatar image sarim987 · Mar 26, 2014 at 10:49 AM 0
Share

What if I made it so when it collides with that building and it's duplicated buildings, it shows the GUI texture. Would that work? How should I approach that?

0 Replies

· Add your reply
  • Sort: 

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

20 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 avatar image avatar image avatar image

Related Questions

How to use Sphere colliders to detect the "Player" 1 Answer

Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer

Collider and Distance Problem OnMouseDown 1 Answer

OnMouseEnter over a Collider, what's the distance? 1 Answer

Input.GetKeyDown and OnTriggerEnter problem. 2 Answers


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