How to make the camera to focus on a player

i know how to rotate around player but i want the camera to sort of like track the player were ever he is. and i don’t want the camera to rotate as the player does.


If I get your point right you want that the camera always keep the same looking direction in world space, and simply translates to keep the player in sight. There is a script doing just this in the AngryBots Unity example project. You may want to have a look at and borrow from it.

The main idea is that you have a camera looking direction vector, let’s call it vCam and assume it is of length 1. And you have a player located at position pPlayer, located at a distance dCam from the camera. The most rough way of doing tracking is to set the position of the camera to (pPlayer - dCam * vCam) on each Update. Such a basic solution will not do any nice movement smoothing or such things though. That’s why you should check out the script in AgryBots, it’s more sophisticated.