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):
return
else:
current_point += 1
rotate_y(-90)
camera.rotate_y(-90)
camera.offset=Vector3(-10,5,0)
direction = (points[current_point].translation - translation).normalized()
if Input.is_action_pressed("ui_left"):
velocity.x = lerp(velocity.x, -max_speed, 0.1) ##### Here #####
rotate_z(deg2rad(max_speed/5))
if Input.is_action_pressed("ui_right"):
velocity.x = lerp(velocity.x, max_speed, 0.1) ##### Here #####
rotate_z(deg2rad(-max_speed/5))
if !is_on_floor():
velocity.y -= max_speed/12
move_and_slide(velocity)