#Help with rigidbody3d sphere-based car controller

1 messages · Page 1 of 1 (latest)

loud siren
#

its not letting me upload the video, but here is the code

#

    pivote_visual.global_position = ball.global_position


    speed_input = Input.get_axis("ui_down", "ui_up") 
    rotate_input = Input.get_axis("ui_right", "ui_left")


    if ball.linear_velocity.length() > 0.5:
        var turn = rotate_input * turn_speed * delta
        car_mesh.rotate_y(turn)


    var forward_dir = -car_mesh.global_transform.basis.z

    if ground_ray.is_colliding():

        ball.apply_central_force(forward_dir * speed_input * acceleration)
    else:

        ball.apply_central_force(Vector3.DOWN * 50.0)


    var velocity = ball.linear_velocity
    velocity.x = drag
    velocity.z= drag
    ball.linear_velocity = velocity```