Advertisement
otorp2

new kinematic movement

Jul 22nd, 2015
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. extends KinematicBody2D
  2.  
  3. # member variables here, example:
  4. # var a=2
  5. # var b="textvar"
  6. const GRAVITY = 200.0
  7. const WALK_SPEED = 50
  8.  
  9.  
  10. var velocity = Vector2()
  11.  
  12. func _fixed_process(delta):
  13. if Input.is_action_pressed("ui_up"):
  14. velocity.y = -WALK_SPEED
  15. elif Input.is_action_pressed("ui_down"):
  16. velocity.y = WALK_SPEED
  17. elif Input.is_action_pressed("ui_left"):
  18. velocity.x = -WALK_SPEED
  19. elif Input.is_action_pressed("ui_right"):
  20. velocity.x = WALK_SPEED
  21. else:
  22. velocity.x = 0
  23. velocity.y = 0
  24. var motion = velocity * delta
  25. move( motion )
  26. var col = get_collider()
  27. if is_colliding():
  28. print(col)
  29. func _ready():
  30. set_fixed_process(true)
  31. # Initialization here
  32. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement