Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var target : Transform;
- var damping = 6.0;
- var smooth = true;
- var offset = 5.0;
- @script AddComponentMenu("Camera-Control/Smooth Look At")
- function LateUpdate () {
- if (target) {
- if (smooth)
- {
- // Look at and dampen the rotation
- var rotation = Quaternion.LookRotation(target.position - transform.position);
- transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
- }
- else
- {
- // lookat
- transform.LookAt(target);
- }
- }
- if (!target) {
- // There was no target, so try to find one.
- target = GameObject.Find ("Camera_Target").transform;
- }
- }
- function Start () {
- // Make the rigid body not change rotation
- if (rigidbody)
- rigidbody.freezeRotation = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement