0 votes

I found it kind of hard to work on a character based on RigidBody, so I tried using KinematicBody instead. I just want to know if it's possible to move a character vertically at an angle with any speed variable. Sorry for the lack of code, just assessing my options. Any example would be great.

Godot version 3.2
in Engine by (14 points)

1 Answer

+1 vote

Consider adapting a simple controller like this as the base for your character controller (It's in 2d but the same principles apply for 3D).

Then, if you want a rocket jump, it would be very similar to a jump, just instead of just changing the velocity in the y axis, you would change it in the x and z as well.

For Example:

if Input.is_action_just_pressed("rocket_jump"):
        if is_on_floor(): #May or may not need this check depending on what you want in your game
            velocity.y = 0
            velocity += rocket_speed * rocket_angle

Where rocketspeed is a predefined float value dictating the power of the rocket, and rocketangle is a normalized vector3 which dictates the launch direction.

Hope this helps, I'm happy to answer any more questions you may have.

by (397 points)

Could you elaborate more on that Vector3? Like how I'd assign values to it if possible. Also thanks in advance, kind of a novice here.

A vector3 contains an x, y, and z value. By giving values for x, y, and z, you can use this to determine the "direction" of the vector.

For example:
Vector3(1, 0, 0) is a vector pointing at the positive x direction
Vector3(0, 1, 0) is a vector pointing upwards in the y direction
Vector3(1, 1, 0) is a vector pointing both in the forward x and positive y direction. (And as x and y are equal this will be at a 45 degree angle)

The only issue with the last one is that - because of Pythagoras' theorem - it has a length of sqrt(2), not 1. By "normalizing" the vector, this essentially turns this vector into a length of 1, so the speed will remain constant for any direction.

Syntax in godot is Vector3(x, y, z).normalized()

Hope that clarified a little

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 Frequently asked questions and 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 [email protected] with your username.