Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody2D
- const GRAVITY = 200.0
- const WALK_SPEED = 200
- var velocity = Vector2()
- func _fixed_process(delta):
- if Input.is_action_pressed("ui_up"):
- velocity.y = -WALK_SPEED
- elif Input.is_action_pressed("ui_down"):
- velocity.y = WALK_SPEED
- elif Input.is_action_pressed("ui_left"):
- velocity.x = -WALK_SPEED
- elif Input.is_action_pressed("ui_right"):
- velocity.x = WALK_SPEED
- else:
- velocity.x = 0
- velocity.y = 0
- var motion = velocity * delta
- move( motion )
- var col = get_collider()
- if is_colliding(): # colliding with Static, Kinematic, Rigid
- if(col.get_name()=="east wall"): # do something
- #if get_collider(get_name()):
- print ("Collision with ", get_collider().get_name() )
- #if get_collider().get_name().begins_with("north"):
- #print("north wall")
- func _ready():
- set_fixed_process(true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement