Hi. I have a player that rotates to look at the mouse, with left click to move. I've seen tons of examples, but this one is different: it uses one button and rotation. How should I apply acceleration and friction to my player?
extends KinematicBody2D
var screen_size
func _ready():
screen_size = get_viewport_rect().size
export (int) var speed = 300
var friction = 0.05
var acceleration = 0.1
var velocity = Vector2()
func get_input():
look_at(get_global_mouse_position())
velocity = Vector2()
if Input.is_action_pressed('left_click'):
velocity = Vector2(speed, 0).rotated(rotation)
func _process(delta):
get_input()
velocity = move_and_slide(velocity)