Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Cup_Of_Karma |
I’ve very new to coding and I’m not sure what to do…
here is my code:
extends KinematicBody2D
const MAX_SPEED = 100
const FRICTION = 25
var velocity = Vector2.ZERO
func _physics_process(_delta):
var input_vector = Vector2.ZERO
input_vector.x = Input.source.get_action_stregth(“ui_right”) - Input.source.get_action_stregth(“ui_left”)
input_vector.y = Input.source.get_action_stregth(“ui_up”) - Input.source.get_action_stregth(“ui_down”)
input_vector = input_vector.nomalized()
if input_vector != Vector2.ZERO:
velocity = input_vector * MAX_SPEED
velocity = velocity.clamped(MAX_SPEED)
else:
velocity = velocity.move_toward(Vector2.ZERO)
move_and_slide(velocity)