Answers for "simple movement in godot 2d"

3

movement in godot

#3d
extends KinematicBody

var speed = 200
var motion = Vector2()

func _physics_process(delta):
	if Input. is_action_pressed("ui_right"):
		motion.x += speed
	elif Input. is_action_pressed("ui_left"):
		motion.x -= speed
	elif Input. is_action_pressed("ui_up"):
		motion.z -= speed
	elif Input. is_action_pressed("ui_down"):
		motion.z += speed
	else:
		motion.x = 0
		

	move_and_collide(motion)
Posted by: Guest on July-21-2020

Python Answers by Framework

Browse Popular Code Answers by Language