I’m trying to make a top down shooter, similar to that of the old classics (DoDonPachi, 19xx etc), i’ve got my movement code, projectile code and camera code, but within the camera code there is a problem, a problem in the sense that the player is not at the bottom of the screen centered, but instead center to the screen, Ive tried to edit code to change this, but no luck, below is my original code, any ideas on what/how to change would be greatly appreciated.
var height = 20.0;
var distance = 0;
var target : Transform;
function Update () {
transform.position = target.position;
transform.position.y += height;
transform.position.z -= distance;
transform.LookAt(target.position);
}
when you use LookAt this will happen and the object that you are looking at will be in center of the screen and using height and distance you can only change viewpoint angles.
you should change the x axis rotation of the camera to 90 (downward) and then put your code without look at. in this way you can find a distance (less than zero) that will do what you want. just remove lookat and rotate camera to look downward (toward ground).
to place a camera in a position that a certain object be in a special position in screen space, you should solve some equations which are not needed here at all.
var height = 20.0;
var distance = -1;
var target : Transform;
function Update () {
transform.position = target.position;
transform.position.y += height;
transform.position.z -= distance * height;
}
not perfect but this code will do the job for anyone who needs it.