Hey, I'm building a pong with godot using gdscript and when I move the player's racket, it doesn't move, I have the up and down keys configured, in addition to the script, but I still can't get it to move, does anyone know? what can be wrong?
extends Node
class_name PlayerInputComponent
var player
# Called when the node enters the scene tree for the first time.
func _ready():
player = get_parent()
player.connect("update", self, "handle_input")
func handle_input():
if not "direction" in player:
return
player.direction = Vector2()
if Input.is_action_pressed("ui_up"):
player.direction.y -= 1
if Input.is_action_pressed("ui_down"):
player.direction.y += 1
extends KinematicBody2D
signal update
export var move_speed = 250
var direction = Vector2()
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _process(delta):
emit_signal("update")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
if direction.length() > 0:
move_and_collide(direction * delta)