Archive

Posts Tagged ‘orthographic camera’

May 13, 2012 Leave a comment

I’ve been scratching my head to think about the best way to do a 3D top down scroller where player can still tap on their iOS and move player and still have 3D depth environments being rendered correctly.

I faced 3 problems here:
1. Touch position doesn’t get along with Perspective camera when trying to convert ScreenToWorldPoint, so I have to use orthographic camera.
2. I want it to be 3D rendered, but still have touch conversion and player (must be always visible and no perspective) rendered correctly.
3. I want the player moved with the speed of camera, and yet still can be freely moved around the view port.

So, after spent 1 hour trial and error, the solution is:
1. Make a orthographic camera that only render for player avatar.
2. Make a perspective camera that renders everything else except the avatar, and make this as children to the orthographic camera.
3. I made the player as children to the camera, so as the camera move, player will also move forward and yet we can still control the position of the player with the tap.

So, the root is orthographic camera that has 2 childrens:
1. Perspective camera
2. Player avatar.

This way I can have a accurate touch position conversion that will positioned the avatar everywhere the player want, and still render the environments as 3D in a top down scroller type.

Next phase: Render the avatar and animate