2D Tutorial movement not working

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MrGwasty

this is how my code looks i tried everything re typing it taking other ppl codes looking at other q&a watching yt and trying to make a little change from my some what type of experience with gd script and nothing is working ONLY the vertical movment is working and only going up left so i dont really know what to do

 extends Area2D
export var speed = 400
var screen_size

func _ready():
	screen_size = get_viewport_rect().size

func _process(delta):
	var velocity = Vector2.ZERO
	if Input.is_action_pressed("move_right"):
		velocity.x += 1
	if Input.is_action_pressed("move_left"):
		velocity.x -= 1
	if Input.is_action_pressed("move_down"):
		velocity.y += 1
	if Input.is_action_pressed("move_up"):
		velocity.y -= 1
	if velocity.length() > 0:
		velocity = velocity.normalized() * speed
	position += velocity * delta
	position.x = clamp(position.x, 0, screen_size.x)
	position.x = clamp(position.y, 0, screen_size.y)
:bust_in_silhouette: Reply From: godot_dev_

Your line of code position.x = clamp(position.y, 0, screen_size.y) should be position.y = clamp(position.y, 0, screen_size.y) I believe. Your getting the x and y axis mixed up

ohhh thank you i really didnt notice even tho i re typed it multiple times anyway thank you this rlly helped

MrGwasty | 2022-07-15 16:07