Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 9th, 2012  |  syntax: None  |  size: 0.77 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. MouseOrbit Customization: Place camera on spot orbit
  2. var angles = transform.eulerAngles;
  3. x = angles.y;
  4. y = angles.x;
  5.  
  6. // Make the rigid body not change rotation
  7. if (rigidbody)
  8.     rigidbody.freezeRotation = true;
  9.        
  10. x += Input.GetAxis("Mouse X") * xSpeed;
  11. y -= Input.GetAxis("Mouse Y") * ySpeed;
  12.  
  13. var rotation = Quaternion.Euler(y, x,0);
  14. var position = rotation * Vector3(0.0, 0.0, cameraDelta);
  15.  
  16. transform.rotation = rotation;
  17. transform.position = position;
  18.        
  19. //set position of camera
  20. transform.position  = new Vector3(x, y, z);
  21.  
  22. var angles = transform.eulerAngles;
  23. y = angles.y;
  24. x = angles.x;
  25. z = angles.z;
  26.  
  27. var rotation = Quaternion.Euler(y, x, z);
  28. var position = rotation * Vector3(0.0, 0.0, cameraDelta);
  29.        
  30. transform.rotation = rotation;
  31. transform.position = position;
  32.  }