How to make a smoth spaceship movement?

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

I’m been triyng to make a game about a spaceship that you move and kill enemies in the space but the problem is my movement for the spaceship sucks for the rotation

i want the rotation to be like a game for fast game controlls


extends Area2D

export var rot_speed = 4.6
export var thrust = 500
export var max_vel = 400
export var friction = 0.65

var look_direction = Vector2(1, 0)
var screen_size = Vector2()
var rot = 0
var pos = Vector2()
var vel = Vector2()
var acc = Vector2()
var JUMPBOST = 0 #100 or 0

func _process(delta):
	if Input.is_action_pressed("move_left"):
		rot -= rot_speed * delta
	elif Input.is_action_pressed("move_right"):
		rot += rot_speed * delta
	if Input.is_action_pressed("thrust"):
			acc = Vector2(thrust + JUMPBOST, 0).rotated(rot)
		acc = Vector2(0, 0)

acc += vel * -friction
vel += acc * delta
pos += vel * delta

Just a suggestion: place the code related to moving the space ship in the _physics_process() function, not the _process() function.

Ertain | 2021-11-25 18:34

:bust_in_silhouette: Reply From: Gluon

You can use the interpolate_with() function to create a smooth transition on a rotation.

If you look up this page Interpolation — Godot Engine (stable) documentation in English in the official docs there is a section on transform interpolations which would relate to rotation.