Weird coordinates in the editor

AnthoJackAnthoJack Posts: 10Member
edited December 1969 in 2D
Hey there,<br />I started using Godot recently and I must say I'm impressed and really impatient to finish the tutorial to start making games.<br />Yet, something still bothers me in the 2D editor: why are the Y-coordinates reversed ? I noticed when making the Pong game that despite the size of the window being 640X400, a higher y-coordinate means going down on the window. Thus, to make the pad (or any moving object) go up or to set an object to a certain height, you need to decrease its y-coordinate which i find really counter-intuitive.<br />Is there any way to change some parameters in the editor in order to have the y-coordinates up (and/or to set the origin at the left-bottom of the window) ?<br />Thanks a lot  ;)

Comments

  • danjodanjo Posts: 81Member
    I would find it weired if 0,0 would be in the bottom left corner. Every engine/framework I know has 0,0 in the upper left corner, just like godot
  • BinaryOrangeBinaryOrange Posts: 234Member
    This is how the X/Y coordinate system works in every engine I've ever touched. GameMaker, Unity, DarkBASIC Pro, App Game Kit, and even Monkey X. <br /><br />To go "up" in Y, you have to decrease the value of Y. Say you want your character to jump, for example. Instead of adding +5 units to the velocity in Y, you would instead subtract 5 units. <br /><br />So, decreasing the Y position of the paddle in Pong to make it go up makes perfect sense. The top of the window or screen is Y = 0.
  • AnthoJackAnthoJack Posts: 10Member
    maybe it's the same in every game engine you both have ever touched but Mathematically speaking any y > 0 should be above the origin and inverting it, no matter the reason, is awfully counter-intuitive for in the mind of most people going UP is associated with increasing the y-coordinate. Maybe they should let the devellopers choose where they want their origin
  • BinaryOrangeBinaryOrange Posts: 234Member
    It makes sense the way it is, once you are used to it.<br /><br />Think about it - to go down in Y, it makes sense to increase the value.  It's just like going right in X, you must increase the value to do that.  To go left you decrease the value of X.  Likewise, decreasing the value of Y is going up, and increasing it is going further down the screen. <br /><br />Is this the first time you are playing with any game engine (not just Godot)?<br /><br />
  • AnthoJackAnthoJack Posts: 10Member
    on 1461755881:
    <br />Is this the first time you are playing with any game engine (not just Godot)?<br />
    <br />Well it is the first time I'm playing with a 2D game engine (i've also started learning UE4) so until now I was used to the way it's done in maths. I'm sure it was inverted in Godot (and others since you both seem to agree on the fact that it's done this way in other game engines too) for a reason but until the day this reason is explained to me, I'll consider it more intuitive to do it the mathematical way ("+"=UP, "-"=DOWN). Maybe the developpers could add an option to modify the placement of the origin and invert the y-coordinates. I don't know how much code it would require but I don't think (though I'm not an expert) it would require to start all over again and I really think it would improve the flexibility of the engine
  • BinaryOrangeBinaryOrange Posts: 234Member
    Oh, I think I see what you're saying. <br /><br /><br />Yes, Y is indeed "inverted" in 2D as opposed to 3D.  Up in Unreal is +500 in Z (or Y, if you use Unity), so now I understand the confusion. <br /><br />Yes, it took me a while to adjust to that too, but I have been playing around in 2D game development more than 3D lately so now it just seems totally natural to me.  I'm not sure if they could add in the option to "flip" the way it works, as it would make several scripts likely work incorrectly in the long run.  Still, certainly a thing to consider!
  • MegalomaniakMegalomaniak Posts: 998Admin
    I suggest reading up on what order openGL draws/rasterizes the screen-buffer(eye-space) in(you might like the answer)...<br /><br />Andon M. Coleman gives a fairly good answer here IMO, other answers are likely also relevant however.
  • AnthoJackAnthoJack Posts: 10Member
    Thank you Megalomaniak for your link. I now get why they did it that way.<br />And I'm happy that BinaryOrange and I could finally understand each other  :).<br />I don't think inverting the y-axis would create such problems. If it is an option present in the "engine.cfg" file every script for that specific project will run quite well I think. Do you know where I could eventually suggest it to the devs of Godot ? (I would do it myself if I were a better programmer  ;D)
  • AkienAkien Posts: 70Godot Leader
    on 1461735678:
    <br /> maybe it's the same in every game engine you both have ever touched but Mathematically speaking any y > 0 should be above the origin and inverting it, no matter the reason, is awfully counter-intuitive for in the mind of most people going UP is associated with increasing the y-coordinate. Maybe they should let the devellopers choose where they want their origin<br />
    <br />Actually no. Mathematically speaking it all depends on the way you define your system, and in game engines or other OpenGL/DirectX based applications the conventional system is [Ox) pointing to the right of the screen and [Oy) pointing to the bottom of the screen.<br /><br />The system is still cartesian if you consider that the [Oz) axis would be pointing away from the player and into the screen. Which is what makes the most sense, using a cartesian system with [Oy) pointing upwards and [Oz) pointing in your face would be counter-intuitive: the depth of the game starts at the screen, and can go beyond it, but not behind the player.
Sign In or Register to comment.