Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

godot code for movement for topdown game

var velocity = Vector2.ZERO

func _physics_process(delta):
	if Input. is_action_pressed("ui_right"):
		position.x += 4
	elif Input. is_action_pressed("ui_left"):
		position.x -= 4
	elif Input. is_action_pressed("ui_up"):
		position.y -= 4
	elif Input. is_action_pressed("ui_down"):
		position.y += 4
	move_and_collide(velocity * position)
	
 
PREVIOUS NEXT
Tagged: #godot #code #movement #topdown #game
ADD COMMENT
Topic
Name
4+6 =