The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hello everyone,
I have the ball on my stage and it keeps going forward. There are some checkpoints and I successfully change direction at these points. The problem starts right here after the change of direction. I can't make left and right turns from the user after a change of direction. I am confused about what change i need to make where i marked with code

func _physics_process(delta):
velocity= direction* delta * max_speed*10
if translation.distance_to(points[current_point].translation) < 3:
    if current_point +1 == len(points):
        current_point += 1
    direction = (points[current_point].translation - translation).normalized()
if Input.is_action_pressed("ui_left"):
    velocity.x = lerp(velocity.x, -max_speed, 0.1)   ##### Here #####
if Input.is_action_pressed("ui_right"):                   
    velocity.x = lerp(velocity.x, max_speed, 0.1)    ##### Here #####
if !is_on_floor():
    velocity.y -=  max_speed/12
Godot version 3.3.4
in Engine by (46 points)

Just an FYI, the delta parameter doesn't have to be factored into the velocity when using the move_and_slide() function. Also, may I suggest doing the velocity calculation after adjusting the variable. For example:

# Do all the velocity calculations above, then factor in the speed numbers below.
velocity= direction * max_speed * 10

When I don't use delta, the ball stays still and doesn't move at all.
I did what you said about velocity.

Then I don't know what exactly the problem is, since the engine's documentation says that delta doesn't have to be included in the velocity calculation for move_and_slide(). Maybe it has something to do with the use of translations?

it should not equal x while doing the rotation.


if Input.is_action_pressed("ui_left"):
velocity.x = lerp(velocity.x, -max_speed, 0.1) 

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