Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[SOLVED] DrawMesh() not drawing with the correct rotation?

Discussion in 'General Graphics' started by PhilSA, Jan 14, 2021.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,573
    Unity 2020.2.1, URP 10.2.2

    I am drawing meshes with Graphics.DrawMesh() like this, but the drawn meshes are always shown with a "quaternion.identity" rotation no matter what rotation I give them:
    Code (CSharp):
    1.  
    2.     void Update()
    3.     {
    4.         for (int i = _lazers.Count - 1; i >= 0; i--)
    5.         {
    6.             TestLazer lazer = _lazers[i];
    7.             _materialPropertyBlock.SetColor(_shadedColorPropertyId, lazer.Color);
    8.             Graphics.DrawMesh(LazerMesh, lazer.pos, lazer.rot, LazerMaterial, 0, null, 0, _materialPropertyBlock);
    9.  
    10.             // Debug
    11.             Debug.DrawRay(lazer.pos, lazer.rot * Vector3.forward * 5f, lazer.Color);
    12.         }
    13.     }
    14.  
    I know for sure that my "lazer.rot" is correct because my "Debug.DrawRay" at the end of the code block displays the correctly-rotated lazer.

    Any ideas why my rotation isn't working with DrawMesh here?
     
    Last edited: Jan 14, 2021
  2. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,573
    My bad everyone, DrawMesh() works as intended. Was just a dumb mistake on my part
     
unityunity