|
I have an object which is moving around on the plane, I want that, if object move in some direction, camera also move with object. Please guide me how can I do this. Sorry for my bad english
(comments are locked)
|
|
The easiest way would probably be to make the camera a child of the object. If you move the object, the camera will move along. If it's enough to only "focus" on the object as in 'looking at the object', try to use Transform.LookAt @Sebas, I have tried Transform.LookAt, but actually I want that camera moves with the object.
Dec 27 '10 at 11:41 AM
Arman
In that case, the parent/child solution might be best and easiest. You could also apply any movement to camera and object individually, but it really depends what you need this functionality for.
Dec 28 '10 at 01:03 PM
Sebas
What I do in this case is write a script that targets the transform of whatever I want the camera to look at. Then I rotate the camera at it and use a LERP to move it around to where I want. Something kinda like this void lookTarget (Transform _lookTarget) { Quaternion lookAt = Quaternion.LookRotation(_lookTarget.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, lookAt, turnSpeed); transform.position = Vector3.Lerp(transform.position, _lookTarget.position + camOffset, targetMoveSpeed); }
Jul 23 '12 at 01:05 AM
darthbator
(comments are locked)
|
|
If i understand your ? right then you can use "Smooth follow" to make the camera follow a object when it moves. Just search "Smooth follow" in the search bar in unity 3D and select "Smooth follow" and attatch it to the camera, and set the target to the object you want the camera to follow. Then when the object moves the camera konstantly looks at it.
(comments are locked)
|
