+1 vote

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

THE SCRIPS THAT I USE

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)
    else:
        acc = Vector2(0, 0)

acc += vel * -friction
vel += acc * delta
pos += vel * delta
set_position(pos)
set_rotation(rot)
Godot version 3.3
in Engine by (24 points)

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

1 Answer

0 votes

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

If you look up this page https://docs.godotengine.org/en/stable/tutorials/math/interpolation.html in the official docs there is a section on transform interpolations which would relate to rotation.

by (1,635 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 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 webmaster@godotengine.org with your username.