–2 votes

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 physicsprocess(delta):

if(axis == Vector2.ZERO):

velocity = move_and_slide(velocity)

func getinputaxis():
axis.x = int(Input.isactionpressed("uiright")) - int(Input.isactionpressed("uileft"))
axis.y = int(Input.isactionpressed("uidown")) - int(Input.isactionpressed("uiup"))

func applyfriction(frictionfactor):
if velocity.length() > frictionfactor:
velocity -= velocity.normalized()*friction
velocity = Vector2.ZERO

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

in Engine by (10 points)

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.

1 Answer

–1 vote

I don't know the question.

by (511 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.