Advertisement
MutualTeats

Camera Movement

Aug 13th, 2013
72
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public GameObject player;  
  2.  
  3. float offsetX = 0;             
  4. float offsetZ = -15;           
  5.  
  6. float maximumDistance = 5;         
  7. float playerVelocity = 10;
  8. float movementX;                   
  9. float movementZ;
  10.  
  11.  
  12.  
  13. // Update is called once per frame
  14. void Update (){
  15.        
  16.         movementX = ((player.transform.position.x + offsetX - this.transform.position.x))/maximumDistance;
  17.         movementZ = ((player.transform.position.z + offsetZ - this.transform.position.z))/maximumDistance;
  18.         this.transform.position += new Vector3((movementX * playerVelocity * Time.deltaTime), 0, (movementZ * playerVelocity * Time.deltaTime));
  19. }
Advertisement
RAW Paste Data Copied
Advertisement