+2 votes

I have a script for flying object but I need to move up and down smoothly - slow/stop move? if it is possible for KinematicBody or need RigidBody?
Thanks for help

enter image description here

 extends KinematicBody

var t 
var r

export var FSpeed = 2
export var MSpeed = 2
export var RSpeed = 2

func _process(dt):
    t = get_transform()
    r = get_rotation()

        t.origin += t.basis[2] * MSpeed * dt

        t.origin += t.basis[2] * -MSpeed * dt

        r += Vector3(0,-0.4,0) * RSpeed * dt

        r += Vector3(0,0.4,0) * RSpeed * dt

        t.origin += t.basis[1] * FSpeed * dt

        t.origin -= t.basis[1] * FSpeed  * dt


func _ready():

uiup is forward movement
down is backward movement

in Engine by (450 points)
edited by

As I read the answer here somewhere, so you cannot use apply impulse for KinematicBody, which would be a solution for smooth motion (slow-stop) - impulse only for RigidBody.
Only for KinematicBody play somehow with gravity?...or am I completely off?
So the solution- RigidBody and apply the impulse(for RigidBody only)

THIS is flying script for like a hovercraft where is set apply impulse to the RigidBody ("hovercraft") but the problem here is that when cornering to the left-right does not fly forward...I mean left-forward and right-forward.
(Sorry for my bad English)

    extends Spatial

var h = ("hovercraft")

func _ready():
    h = get_node("hovercraft")

func _process(delta):
    if Input.is_action_pressed("move_up"):
        h.apply_impulse(Vector3(0, 0, 0), Vector3(0, 0.5, 0))
    if Input.is_action_pressed("move_down"):
        h.apply_impulse(Vector3(0, 0, 0), Vector3(0, -0.5, 0))
    if Input.is_action_pressed("rotate_right"):
    if Input.is_action_pressed("rotate_left"):
    if Input.is_action_pressed("forward"):
        h.apply_impulse(Vector3(0, 0, 0), Vector3(0, 0, -0.2))
    if Input.is_action_pressed("brake"):
        h.apply_impulse(Vector3(0, 0, 0), Vector3(0, 0, 0.2))

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 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.