Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Can't get my scripted mesh working right.

Discussion in 'Scripting' started by kauanfontanela09, Jan 25, 2021.

  1. kauanfontanela09

    kauanfontanela09

    Joined:
    Jan 25, 2021
    Posts:
    2
    So, I was looking for a way to get a curve as customizable as possible, although the mesh looks good, its material seem to be bugged and the lights don't look well either.

    The light reflecting on it looks pretty weird shaped, and there's also this pink mesh that stays at (0, 0, 0) position even if I move the object.


    The way i'm making this mesh is by changing its MeshFilter.mesh (or sharedMesh when its running in EditMode) i get the MeshFilter's mesh and define it's values.
    I already tried changing the ui values, but it doesn't help. I can't find a solution for this anywhere, i'm really frying my brain at this point. If anyone could help me with it, i'd be really thankful!
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,780
    By sharing vertices at a corner the lighting will never be correct at that corner. UV and lighting (normals) are shared on a per vertex basis, so at a 90-degree bend you need to add the vertex twice: once for the horizontal part, once for the vertical part. This applies everywhere except in between coplanar faces if you want the lighting to look right.

    You're welcome to look at some examples in my makegeo package.

    MakeGeo is presently hosted at these locations:

    https://bitbucket.org/kurtdekker/makegeo

    https://github.com/kurtdekker/makegeo

    https://gitlab.com/kurtdekker/makegeo

    https://sourceforge.net/p/makegeo
     
    kauanfontanela09 and SparrowGS like this.
  3. kauanfontanela09

    kauanfontanela09

    Joined:
    Jan 25, 2021
    Posts:
    2
    Thank you very much! Didn't got time to test it out, but I certainly will, once again, thank you for your help, it really means a lot!
     
    Kurt-Dekker likes this.