Search Unity

Coordinate system, right hand or not & headings

Discussion in '2D' started by Reloque, Nov 22, 2019.

  1. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    207
    So, Unity, if I am not mistaking, uses a right hand coordinate system. Meaning a positive rotation along the z axis in a top down 2d game is counterclockwise and a 90 degree heading is due west.

    In navigation, looking down on a ship from above, a positive rotation along the z axis changing the heading is clockwise and a 90 degree angle is due east. https://en.m.wikipedia.org/wiki/Heading_(navigation)

    So, combining those worlds, I am making a top down game that has ships. The player, will expect a 30 degree turn to slightly turn him towards the east. Unity will make a 30 degree turn to go slightly to the west. Of course, I can quite simple just do this;

    Code (CSharp):
    1. rotation.Value = quaternion.RotateZ(targetHeading * -Mathf.Deg2Rad);
    But that feels wrong somehow. What would be a good way to handle this situation?
     
  2. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    What seems to be the problem? Everything seems fine to me, and even if it feels wierd, write that line of code into a wrapper function and voila you can use it the way you expect it to
     
  3. Reloque

    Reloque

    Joined:
    Apr 28, 2015
    Posts:
    207
    Well yes, I could. But it feels strange to circumvent this.