Use lookAt and transform.translate at the same time

I’m trying to get a camera, pointing down towards a rectangle, to move on the x axis using the accelerometer and, at the same time, to always point at the center of the rectangle (which is, coordinates 0,0,0). So, the camera should move and rotate to always look at the center of the rectangle. The purpose is to give a sense of “false 3D”, for lack of a better description.

I can make the camera move, but I can’t make it rotate accordingly. When I use lookAt, the whole thing spins on the y axis instead of rotating on z axis. It looks like I can’t use transform.translate and lookAt in the same function.

I’m really at a loss, here. I literally can’t think of any way to fix this. It would be awesome if someone could help.

Anyway, here is the code I’m using to make it move. What should I add/change?

function Start () {

var camSpeed = 20;

function Update () {

//var dir : Vector3 =;
var dir : Vector3;
dir.x = -Input.acceleration.y; 
dir *= Time.deltaTime;
transform.Translate (dir * camSpeed);


Your problem is using Translate without a specific second parameter of - currently the translation happens in the rotation of the object - which gives you the spinning effect. You presumably want movement in world coordinates and then the look at should keep it centered…