godot code for movement for topdown game

Solutions on MaxInterview for godot code for movement for topdown game by the best coders in the world

showing results for - "godot code for movement for topdown game"
Celise
19 Nov 2016
1var velocity = Vector2.ZERO
2
3func _physics_process(delta):
4	if Input. is_action_pressed("ui_right"):
5		position.x += 4
6	elif Input. is_action_pressed("ui_left"):
7		position.x -= 4
8	elif Input. is_action_pressed("ui_up"):
9		position.y -= 4
10	elif Input. is_action_pressed("ui_down"):
11		position.y += 4
12	move_and_collide(velocity * position)
13