i dont know the problem

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

extends KinematicBody2D

export var maxSpeed = 500
export var acceleration = 2000
export var friction = 10000

var axis = Vector2.ZERO
var velocity = Vector2.ZERO

func _ready():

func _physics_process(delta):

if(axis == Vector2.ZERO):
velocity = move_and_slide(velocity)

func get_input_axis():
axis.x = int(Input.is_action_pressed(“ui_right”)) - int(Input.is_action_pressed(“ui_left”))
axis.y = int(Input.is_action_pressed(“ui_down”)) - int(Input.is_action_pressed(“ui_up”))

func apply_friction(friction_factor):
if velocity.length() > friction_factor:
velocity -= velocity.normalized()*friction_factor
velocity = Vector2.ZERO

func apply_motion(acc_factor):
velocity += axis*acc_factor
velocity = velocity.clamped(maxSpeed)

We don’t know the problem either because you didn’t describe it.

  • Are you getting an error? If so, what is it, exactly?
  • Does it not work correctly? If so, what should it do and what is it doing instead?
  • Something else?

Also, please edit you post, select the code portion, and click the { } button in the editor’s toolbar to format the code for the forum. That’ll make it much easier to read.

jgodfrey | 2022-08-09 22:11

:bust_in_silhouette: Reply From: SteveSmith

I don’t know the question.