0 votes

What I have doesn't work in Fullscreen and I cant figure out how to add acceleration similarly to my movement acceleration for when joystick input is being used

extends KinematicBody2D

var playerMaxSpeed: int = 300
var playerAccel: int = 2250
var player
Friction: int = 2250

var mouseSensitivity= 500
var mouse
Accel = 100
var velocity = Vector2.ZERO

func physicsprocess(delta):

var look_Vector = Vector2.ZERO
look_Vector.x = Input.get_action_strength("RS_right") - Input.get_action_strength("RS_left")
look_Vector.y = Input.get_action_strength("RS_down") - Input.get_action_strength("RS_up")

if abs(look_Vector.x) == 1 and abs(look_Vector.y) == 1:
    look_Vector = look_Vector.normalized()
var aim_Vector = mouse_Sensitivity * look_Vector * delta
if (aim_Vector):
    Input.warp_mouse_position(get_viewport().get_mouse_position() + aim_Vector)


var inputAxis = get_input_axis()
if inputAxis == Vector2.ZERO:
    apply_friction(delta)
else:
    apply_Accel(inputAxis * player_Accel * delta)
velocity = move_and_slide(velocity)
look_at(get_global_mouse_position())

func getinputaxis():
var inputAxis = Vector2.ZERO
inputAxis.x = float(Input.getactionstrength("right")) - float(Input.getactionstrength("left"))
inputAxis.y = float(Input.getactionstrength("down")) - float(Input.getactionstrength("up"))
return inputAxis.normalized()
func applyfriction(delta):
velocity= velocity.move
toward(Vector2.ZERO, playerFriction * delta)
func apply
Accel(playerAccel):
velocity += player
Accel
velocity = velocity.limitlength(playerMaxSpeed)
func apply
MouseAccel(Accel):
velocity += playerAccel
velocity = velocity.limit
length(playerMaxSpeed)

Godot version 3.5.1
in Engine by (21 points)

Please log in or register to answer this question.

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.