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 AxillarHD · May 17, 2013 at 01:11 AM · collisionerrortextureshow

Showing a picture on collision errors

Hi! I am trying to make it so that when I touch a game object, it will display a picture, and then when you stop touching it the picture will disappear. I have tried looking through others answers, but I am getting errors with their scripts. I tried looking through the show gui on collision and show 2D texture on collision but I can't figure out how to get them working. I am a complete beginner when it comes to scripting so if anyone could please explain it to me it would be GREATLY appreciated. Thanks so much for any help!

Comment
Add comment · Show 3
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 rutter · May 17, 2013 at 01:13 AM 0
Share

Are you having trouble detecting clicks, showing pictures, or both?

avatar image AxillarHD · May 17, 2013 at 01:30 PM 0
Share

I'm honestly not even sure which script to use. Would a script to display a gui work or is there a specific way to display a 2d texture when you click an object?

avatar image AxillarHD · May 17, 2013 at 01:31 PM 0
Share

So i guess I am having trouble with both.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by MD_Reptile · May 17, 2013 at 02:08 PM

so all you need is for a picture to cover the whole view of the screen when a collision happens to a certain object?

well, you could place a plane which covers the view entirely, blocking all other objects, and simply turn on the renderer when the collision happens. You would want to apply the texture of your image to the plane.

(in C#):

     void OnCollisionEnter(Collider other)
     {
         if(other.gameObject == TargetGameObject) // set this as public var in inspector, place the object you want to trigger there
         {
             // first position the object in the editor, if you move your camera make it a child of the camera
             other.gameObject.renderer.enabled = true; // then make sure you disable the renderer (checkbox) so that you cant see it until the trigger happens
         }
     }



or your could try GUITexture, and do something similar but instead of enabled renderer, enable the guitexture.

Or maybe im wrong, you need it so that a mouse click triggers the picture?

if it can be a mouse click anywhere, the just check for a mouse click and enable the renderer (this would be in update() method):

 if(Input.GetKeyDown(KeyCode.Mouse0))
         MyPlaneObject.renderer.enabled = true;



and assign myplaneobject as the plane.

buttt if it has to be a mouseclick only on an object, its often easier to just raycast from your mouse position (when you click) and if it hits the object, then trigger the method, but this gets to be more project specific, and I cant really give a solid example offhand

Comment
Add comment · Show 2 · 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 AxillarHD · May 17, 2013 at 04:56 PM 0
Share

Thanks for your detailed response! Yes sorry I made a mistake I want it to be on mouse click not the player collision. And it would be clicking a specific object. Since you can't give a solid example do you know of a good tutorial that would $$anonymous$$ch me how to do this? THanks for your time :)

avatar image MD_Reptile · May 18, 2013 at 12:30 PM 0
Share

@axillarhd When I first started with unity I really learned a lot from 3dbuzz (google em) - they have some good examples for learning many of these sorts if things.

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

15 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

Related Questions

Multiple Cars not working 1 Answer

Block Collision Sliding off 0 Answers

Collision destroy help. 1 Answer

Tags not working? 1 Answer

Show enemy health on collision help. 3 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