Search Unity

Help implementing a 2D mini game in 3D

Discussion in 'Editor & General Support' started by anxietywithfries, Mar 25, 2022.

  1. anxietywithfries


    Feb 11, 2022
    I'm developing a game in Unity 3D. The basis of the game is that it takes place in a room, and clicking on different objects launches different 2D minigames. I want to implement a floor-sweeping minigame, where you click on a broom, and it brings up a picture of a floor with dirt on it, that you use your mouse to "clean", like how you clean a window in House Flipper.

    I'm having difficulty figuring out how to implement this in 3D. In the research I've done, I found ways to implement this in 2D using sprite masks, but this doesn't appear to be a feature in the Unity 3D UI elements. How would this have been implemented in House Flipper? And what's the simplest way to approach doing this in Unity 3D?

    Any help or pointers to subjects to do more research on would be greatly appreciated. Thanks.
  2. Kurt-Dekker


    Mar 16, 2013
    I imagine your first research would be to figure out how you want to represent dirt in 3D. Meshes? A neat shader trick such as hair? Particles of some kind?

    Until you figure that out and mock up something you're pleased with, you really don't have anything to even try to play with to clean up.

    The first place I would try is making a bunch of random tiny black Unity default cubes spawn on the floor, your "dirt particles" and then get scripting to make those go away.

    Once you understand that gameplay loop, everything else is just iteration.

    Trivial elemental steps that make up this loop, all of which you can learn and practice with Youtube tutorials:

    - spawning dirt randomly over an area?
    - or just emplace a bunch of dirt by hand for the first room
    - reading touch or mouse input
    - casting into the scene
    - deleting things nearby the impact point
    - making a scrub-a-dub particle system

    Tutorials and example code are great, but keep this in mind to maximize your success and minimize your frustration:

    How to do tutorials properly, two (2) simple steps to success:

    Tutorials are a GREAT idea. Tutorials should be used this way:

    Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That's how software engineering works. Every step must be taken, every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly, literally NOTHING can be omitted or skipped.

    Fortunately this is the easiest part to get right: Be a robot. Don't make any mistakes.

    If you get any errors, learn how to read the error code and fix your error. Google is your friend here. Do NOT continue until you fix your error. Your error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.

    Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

    Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost. If you want to learn, you MUST do Step 2.

    Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there's an error, you will NEVER be the first guy to find it.

    Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!