Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. var target : Transform;
  2. var damping = 6.0;
  3. var smooth = true;
  4. var offset = 5.0;
  5. @script AddComponentMenu("Camera-Control/Smooth Look At")
  6.  
  7. function LateUpdate () {
  8. if (target) {
  9. if (smooth)
  10. {
  11. // Look at and dampen the rotation
  12. var rotation = Quaternion.LookRotation(target.position - transform.position);
  13. transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
  14. }
  15. else
  16. {
  17. // lookat
  18. transform.LookAt(target);
  19. }
  20. }
  21. if (!target) {
  22. // There was no target, so try to find one.
  23. target = GameObject.Find ("Camera_Target").transform;
  24. }
  25. }
  26.  
  27. function Start () {
  28. // Make the rigid body not change rotation
  29. if (rigidbody)
  30. rigidbody.freezeRotation = true;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement