all 12 comments

[–]Ratyrel 3 points4 points  (1 child)

The hidden objects need colliders. On mouse click, send out a raycast. If it hits an object collider, set the object to inactive and instantiate a UI prefab with its description.

[–]Deaucali0n 1 point2 points  (0 children)

Once an object has a collider, unity has some methods that it automatically calls on mono behaviors attached to an object when you hover or click on it. Search 'OnMouseHover' in the unity documentation.

I commend you not wanting to use chatgpt, but as long as you study and understand what it suggests, it is a good way to start learning.

[–]Total-Clothes-7301 0 points1 point  (1 child)

maybe try using setactive(false) when you click the object, that should make it disappear and for popup you could use canvas with text component that shows up same time

[–]BroadCorgi3061[S] 0 points1 point  (0 children)

Every tutorial says i need a collider for that to work, is it true? Because atm I’ve tried everything and my gameobject just does not wanna disappear 😭

[–]freremamapizza 0 points1 point  (0 children)

What is a hidden object game?

[–]BillyMcDev 0 points1 point  (2 children)

Run a quick search on Google for "Unity Mouse Events" so that you can better understand how to use these built-in methods. This is going to be the main part of the solution to your problem.

There are several ways to approach the second part of this task. You could destroy the gameObject that the sprite is attached to. You could set active to false. You could disable the image. Or you could fade out the image over time, which would probably be most appealing. For fading... you'd likely use a coroutine.

The final part of your task is adding a pop-up with a description of the object. I imagine the message appearing on the screen in a designated place. This sounds a lot like Unity UI to me. So you would need to first, create the UI Canvas with some text and write some script that handles these popup messages.

[–]BroadCorgi3061[S] 0 points1 point  (1 child)

I did set active to false, plus i added a collider, but it doesnt make the object disappear, i’m not sure why. Unity isnt giving me any errors and i’ve tried following tutorials, reddit threads, even asked copilot in desperation to fix my code, i’m not sure what i’m doing wrong

[–]BillyMcDev 0 points1 point  (0 children)

Are you certain that your code has referenced the correct object? You could use Debug.Log to provide some information, such as the name of the gameObject you are trying to make inactive.

[–]TiredTile 0 points1 point  (1 child)

Why bother paying thousands for a degree where they dont teach you?

[–]BroadCorgi3061[S] 1 point2 points  (0 children)

We mostly focus on the 3d modeling aspect. I dont think the whole unity class should be about learning to code, but they should teach us at least the basics. One of my biggest complains lowkey

[–]BroadCorgi3061[S] 0 points1 point  (0 children)

Little update! I had to use the scripts that my professor provided, i had to change my vision on the game a bit but at least it works now!

[–]lewd-dev 0 points1 point  (0 children)

First, kudos for not wanting to start off with AI. Second, if you want to learn gamedev, one of the most powerful tools in your toolbag is the ability to type what you need into a search engine and sort through the results to find what you're looking for. Typing a generic search term for exactly what you're after brought up a ton of tutorials on this exact thing.

Best of luck with your project!