Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

how to make the corners of my prefab not overlap

Discussion in 'Prefabs' started by JulioNicacio, Apr 4, 2022.

  1. JulioNicacio

    JulioNicacio

    Joined:
    Jan 3, 2021
    Posts:
    3
    I'm having a hard time getting the corners of my prefab not to overlap, but to make something more uniform that looks like one piece. Does anyone know what strategy I could have to fix this? I am grateful in advance for any advice

    upload_2022-4-4_16-41-38.png

    upload_2022-4-4_16-41-43.png



    OBS: The second image is my original prefab that I expand and make it form 4 rectangles getting the shape of the first image.
     
  2. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    604
    This has nothing to do with prefabs. You would have exactly the same problem if you used 4 unique meshes with similar shape and no prefabs. That's simply how 3d graphics with current graphics APIs and hardware in most software works. Having two surfaces on the same plane (or very close) will result in unpredictable results like that. You may read about "z fighting" if you want to dive deeper into more technical details. There are techniques for mitigating it in special cases and non polygon based 3d modeling, but in many cases it's more practical to just avoid placing objects like that.

    In your specific cases I can think of couple of approaches depending on what kind of visuals you want, and how much effort you want to put in for this object. Just like with making real life picture frame, you have to choose what kind of corner joint you want.
    a) Have 2 of the side shorter and 2 longer. This requires least amount of work but might not look as good depending on the kind of 3d profile you use.
    b) create 2 different meshes: one for the sides, one for the corners. Make the whole frame from 4 side parts and 4 corners.
    c) Create the whole thing 3d modelling software which will give you a lot more tools for manipulating geometry. You could then use either specialized extrusion tool, boolean operations or simply manually edit the the vertices in corners.

    Last 2 options take a bit more work, but give you full creative control of how the corner joints should look like. Do you want 45 degree cut, grooves crossing, high points crossing, rounded corners and grooves, or maybe something else.
     
  3. olejuer

    olejuer

    Joined:
    Dec 1, 2014
    Posts:
    211
    I second everything @karliss_coldwild said.

    There is an alternative to create a mesh with 45 degree angle (like a trapezoid). You could stick together four of those.
    If you don't want visible lines between the parts, you will want to make one single mesh for it, though.
    You could use ProBuilder for this, since it's a rather simple mesh https://unity.com/features/probuilder
    I would recommend to learn some blender basics and make it in there.