3D Isometric Camera C# - Center on player?

Hi there,

Some background info here, but if short on time and/or just want the final question, skip to bottom.

I’m very new to Unity, I know most of the basics, though. I’ve done the 3Dbuzz platformer tutorials, I’ve done a few others as well. I am a Creature TD with above professional level ability who can create professional film & game quality rigs - this has given me an understanding of programming concepts originating with python. Now I am learning C# within unity, I understand most of the concepts necessary for programming with C# or at least a good basis to start with.

But I’m getting stuck on simple things, I feel like there’s too much stuff I don’t know that I should know. Is there a resource I’m missing for things like this? :

I am making a 3D isometric game. The camera only ever follows the player around, that is all it has to do. It is point and click and will be using a pathfinding system from the asset store both for moving the player and the AI. I’ve coded the necessary rays for detecting player clicks and placing them on the X/Z grid.

So the camera: My camera script checks if a main camera exists, if not, it will create one and the camera will have 0, 0, 0 position and rotation, but with an orthographic projection (instead of perspective). The empty object that the camera is parented to will be lifted up on Y, rotated by 30 degrees on X, and 45 degrees on Y to create the isometric view.

------------TLDR & final question -----------

How do I make my isometric camera always have the player centered on the screen? It should spawn centered, and remain centered as the player moves. Even could just parent the camera under the player (kind of a cheap hack) but then I still need him centered to begin with.

Well your cheap hack sounds exactly what you need. Especially as the camera is not to move independently then it should be configured this way, anything else would just be costing performance for no reason. Just arrange the camera so the character is in the centre of the view and you are done.

One thing I used when trying to pick up Unity programming was the Most Voted button on Unity Answer’s question lists - that shows you things that other people have found important.

Here is my solution:

void LateUpdate () {
		if (takipEdilecek) {			
			Vector3 kameraYeniPosisyon = takipEdilecek.position - (transform.rotation * Vector3.forward * mesafe);
			transform.position = Vector3.Lerp (transform.position, kameraYeniPosisyon, Time.deltaTime * 2);
		}
	}

takipEdilecek: Object which is followed by cam.
kameraYeniPosisyon: Cam’s new position.
mesafe: Cam’s distance to object.
(Script is attached to cam)