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

Problem with rotation when converting 2d game to 3d game

Discussion in 'Scripting' started by i1vandar1o, Apr 12, 2020.

  1. i1vandar1o

    i1vandar1o

    Joined:
    Jan 6, 2019
    Posts:
    2
    Hi, I had a 2D game project and wanted to make an npc that would follow me and I found out that the way to do that was to use Mesh renderer with 3D objects so I had to convert the game to 3D and rotate all sprites for X = 90, the main camera was also rotated and placed in orthographic projection.
    When the game was 2D, the bullet with the direction transform.up = worked perfectly, but now the rotation is strange, I can see the bullet only if I shoot full up or down because the rotation allows me to see it, but in the other directions rotation rotates the way I can't see.
    I do not know how fix it, sorry.

    i will put an image with the trigger output sprite, is the same problem.
    upload_2020-4-11_23-9-19.png upload_2020-4-11_23-9-51.png

    Here the rotation is weird, one part of the sprite hides behind white background
    upload_2020-4-11_23-11-7.png
    This is happening
    upload_2020-4-11_23-13-0.png

    then full left or right and rotate until this and we can't see

    upload_2020-4-11_23-17-35.png
     
  2. mattKsp

    mattKsp

    Joined:
    Jul 15, 2014
    Posts:
    15
    (I appologise that this will not answer your question, but there are reasons..)

    1st - there is not enough information presented here to help you.
    2nd - pretty certain you can do all this in 2D
     
    i1vandar1o likes this.
  3. Xiromtz

    Xiromtz

    Joined:
    Feb 1, 2015
    Posts:
    65
    Transform.up moves along Vector3.up, which is: (0,1,0), so along the y-axis.
    By rotating everything along the x axis by 90 degrees, you have changed your axis of movement from the y axis to the z axis.
    The solution: Use Transform.Forward (0,0,1) instead of Transform.Up (0,1,0)
     
    i1vandar1o likes this.
  4. Xiromtz

    Xiromtz

    Joined:
    Feb 1, 2015
    Posts:
    65
    Additionally, you might have to change your rotation code to use the Y-Axis (0,1,0) instead of the Z-Axis (0,0,1)
     
    i1vandar1o likes this.
  5. i1vandar1o

    i1vandar1o

    Joined:
    Jan 6, 2019
    Posts:
    2
    Thank you.
     
  6. mattKsp

    mattKsp

    Joined:
    Jul 15, 2014
    Posts:
    15
    Ahh... Thats what you were getting at.. Sorry I couldnt help.