Advertisement
Guest User

camera2

a guest
Jan 18th, 2014
6,033
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. from bge import logic
  2.  
  3. def Camera():
  4.  
  5. cont = logic.getCurrentController()
  6.  obj = cont.owner
  7.  sce = logic.getCurrentScene()
  8.  
  9.  def Init():
  10.  
  11.  if not 'init' in obj:
  12.  
  13.  obj['init'] = 1
  14.  obj['target'] = sce.objects['Player']
  15.  obj['depth'] = obj.position.y - obj['target'].position.y
  16.  
  17.  def Update():
  18.  
  19.  tarpos = obj['target'].worldPosition
  20.  pos = obj.worldPosition
  21.  
  22.  soft = 1
  23.  obj.position.x += (tarpos.x - pos.x) * soft
  24.  obj.position.y += (tarpos.y + obj['depth'] - pos.y) * soft
  25.  
  26.  Init()
  27.  Update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement