Help with my 3rd person camera script.

The problem I’m having is that when I move the camera on the x Axis it moves according to the world. Is there a function to move it on its local x so that I can make it circle around the player. I can’t find anything in the scripting reference. I’ve already come up with different ways to make a 3rd person camera work but before I try to check those I want to save time by using this way.

var hero : GameObject;
var height : float;
var distance : float;

function Start ()
	hero = GameObject.FindWithTag("Player");

function Update ()
	transform.position.y = hero.transform.position.y + height;
	transform.position.z = hero.transform.position.z - distance;
	if (Input.GetAxis("CamSide") < 0)
		transform.position.x -= 2 * Time.deltaTime;
	if (Input.GetAxis("CamSide") > 0)
		transform.position.x += 2 * Time.deltaTime;

Hi, superluigi,

transform.rotateAround(point, axis, degree) seems to be the function you are looking for.


Try this link for a community developed MMO like camera with orbit, the code there might help you with your orbit issue.

Updated - left out the link!