Last active
          August 2, 2016 15:41 
        
      - 
      
- 
        Save neikeq/48045d8037a79830c846a22796926b9f to your computer and use it in GitHub Desktop. 
    WARNING: Should modify the camera offset instead of its position. Check: https://gist.github.com/blurymind/18c08bd2a617eeb102ed237c0d62ae85
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | extends Camera2D | |
| var dragging = false | |
| var drag_from = Vector2() | |
| func _ready(): | |
| set_process_unhandled_input(true) | |
| func _unhandled_input(event): | |
| if event.type == InputEvent.MOUSE_BUTTON and not event.is_echo(): | |
| if event.pressed: | |
| drag_from = event.pos | |
| dragging = true | |
| else: | |
| dragging = false | |
| elif event.type == InputEvent.MOUSE_MOTION and dragging: | |
| translate(drag_from - event.pos) | |
| drag_from = event.pos | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment