Question by
sourav13 · Jul 15, 2016 at 12:59 PM ·
coordinate-system
Converting from viewport cooridantes to 2d coordinates.
I have my game objects in coordinate system starting (0,0) at lower left and increasing x and y upwards (1,1) at the top right , what's the easy way to convert it to the 2d coordinate (0,0) at the centre and -x to left ,positive x to right , -y downwards and +y upwards (and its size is 0,0 at centre to screen width and height).
Comment
Answer by tanoshimi · Jul 15, 2016 at 01:13 PM
I'm not quite sure what your last sentence means: "its size is 0,0 at centre to screen width and height". So what is at the bottom left hand corner of the new coordinate system? Screen width/2 and screen height/2?
I think you might be describing this:
NewX = (OldX - 0.5) * Screen.width;
NewY = (1 - (OldY - 0.5)) * Screen.height;