godot-demo-projects/2d/isometric/troll.gd

30 lines
775 B
GDScript3
Raw Normal View History

extends KinematicBody2D
# This is a simple collision demo showing how
# the kinematic controller works.
# move() will allow to move the node, and will
# always move it to a non-colliding spot,
# as long as it starts from a non-colliding spot too.
# Member variables
2017-06-25 13:00:20 +02:00
const MOTION_SPEED = 160 # Pixels/seconds
2017-10-04 13:12:41 +02:00
func _physics_process(delta):
var motion = Vector2()
if (Input.is_action_pressed("move_up")):
motion += Vector2(0, -1)
if (Input.is_action_pressed("move_bottom")):
motion += Vector2(0, 1)
if (Input.is_action_pressed("move_left")):
motion += Vector2(-1, 0)
if (Input.is_action_pressed("move_right")):
motion += Vector2(1, 0)
2017-06-25 13:00:20 +02:00
motion = motion.normalized()*MOTION_SPEED
# Make character slide nicely through the world
move_and_slide( motion )