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!
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.
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):
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