- Home /
Make Camera follow to Object(3rd person Camera)
Hello everyone,
I have 3d scene in that i have one sphere(Ball) object which is rolling on the floor.
Now i want my camera to follow this sphere. I have tried different script but not able to get the expected result.
The script i have attached to the ball is here:
function Start () {}
function Update () {
FixedUpdate();
}
function FixedUpdate () {
rigidbody.AddTorque (Vector3.right * 10);
}
Camera Script :
public var target : GameObject;
public function LateUpdate(){
transform.LookAt( target.transform );
}
with this script , it is just looking towards my ball. But how to make my my camera to follow this sphere?
Thanks for your help and support..
Answer by Moor · Nov 22, 2013 at 09:27 AM
hi Ekta Mehta D. , just child the camera into sphere (ball)
But my sphere is rolling on the floor, so if i make camera child then it is also rotating with sphere. which i dont want.
take an empty game object add moving script to it,
and add both camera and ball in it, and now add rotating script to ball
other way:
var dist:Vector3=Vector3(0,2,2);
public function LateUpdate(){
transform.LookAt( target.transform );
//dist is a distance between ball and camera as ur wish
transform.position=traget.position-dist;
}
Hmm i have written logic similar to this. thanks sir for helping me..
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Character Runs Off Camera 2 Answers
Rotate camera around player 2 Answers
Unity Camera Follow Tag 1 Answer
Camera follow help? 1 Answer