Advertisement
otorp2

kinematic collision selection

Jul 20th, 2015
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. extends KinematicBody2D
  2. const GRAVITY = 200.0
  3. const WALK_SPEED = 200
  4.  
  5. var velocity = Vector2()
  6.  
  7. func _fixed_process(delta):
  8. if Input.is_action_pressed("ui_up"):
  9. velocity.y = -WALK_SPEED
  10. elif Input.is_action_pressed("ui_down"):
  11. velocity.y = WALK_SPEED
  12. elif Input.is_action_pressed("ui_left"):
  13. velocity.x = -WALK_SPEED
  14. elif Input.is_action_pressed("ui_right"):
  15. velocity.x = WALK_SPEED
  16. else:
  17. velocity.x = 0
  18. velocity.y = 0
  19. var motion = velocity * delta
  20. move( motion )
  21. var col = get_collider()
  22. if is_colliding(): # colliding with Static, Kinematic, Rigid
  23.  
  24. if(col.get_name()=="east wall"): # do something
  25. #if get_collider(get_name()):
  26. print ("Collision with ", get_collider().get_name() )
  27.  
  28. #if get_collider().get_name().begins_with("north"):
  29. #print("north wall")
  30. func _ready():
  31. set_fixed_process(true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement