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…
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.
– Ekta-Mehta-Dtake an empty game object add moving script to it, and add both camera and ball in it, and now add rotating script to ball
– Moorother 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; }
– MoorHmm i have written logic similar to this. thanks sir for helping me..
– Ekta-Mehta-D