0 votes

I need a jetpack system for a kinematicBody2D

Can you help me?

in Engine by (33 points)

1 Answer

+2 votes

You could do something like this:

extends KinematicBody2D

const GRAVITY = Vector2(0, 800)
const JETPACK_BOOST = 200

var velocity = Vector2()

func _physics_process(delta):
    velocity += GRAVITY * delta

    if Input.is_action_pressed("ui_accept"): # Activate jetpack
        velocity.y = -JETPACK_BOOST
        $"Jetpack Particles".emitting = true

    velocity = move_and_slide(velocity)

This is just a very simplistic jet pack as I'm not exactly sure what you are aiming for.

by (156 points)

Thanks!!!! that is what I need!!

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.