Camera Setup for 2D Game

Hi,

I’m new to Unity…just trying a few things, but i can’t figure something out…basically i want to setup my main camera to be the same size as my iphone’s physical screen. That way when i move a gameobject the iphonetouch position x and y directly relates to the position of my gameobject.

I’ve setup my camera to be orthographic, and placed it at 0,0,0 but when i move my gameobject by directly transforming the position with touch x,y it flies off the view of the camera.

I’m thinking i need to set the camera viewport height and width to the iphone’s 320x480 and that would solve my problem, but is this even possible?

Thanks,
Felix

Greetings Felix, I don’t think you’ll be able to accomplish that because Unity is a 3d engine and so the world space and screen space are in different coordinate systems. However there are lots 2d games in Unity; they just setup the camera and constrain motion and rotation and stuff into the correct planes. Like the camera points down (Y) from above the scene and most of your game action is in X and Z.

But you can easily convert between them using ScreenToWorldPoint and related functions.

–Eric

ScreenToWorldPoint is exactly what I needed! Thanks Guys!