Hello, I have a code that seems to have 0 errors, but when I test it nothing happens

So basicaly i am getting this code from YouTube (“KidsCanCode”) and when i type it in it has 0 errors, BUT when i start the project (a plane game) nothing happens:

extends CharacterBody3D

var min_flight_speed = 10
var max_flight_speed = 30
var turn_speed = 0.75
var pitch_speed = 0.5
var level_speed = 3.0
var throttle_delta = 30
var acceleration = 6.0

var forward_speed : float = 0
var target_speed : float = 0

var speed = Vector3.ZERO
var turn_input = 0
var pitch_input = 0

func get_input(delta):
if Input.is_action_pressed(“throttle_up”):
target_speed = min(forward_speed + throttle_delta * delta, max_flight_speed)
if Input.is_action_pressed(“throttle_down”):
target_speed = max(forward_speed - throttle_delta * delta, min_flight_speed)
turn_input = Input.get_action_strength(“roll_left”) - Input.get_action_strength(“roll_right”)
pitch_input = Input.get_action_strength(“pitch_up”) - Input.get_action_strength(“pitch_down”)

func _physics_process(delta):
forward_speed = lerp(forward_speed, target_speed, acceleration * delta)
speed = -transform.basis.z * forward_speed
speed = move_and_slide()

(all my inputs are the same)
Sorry if the code is tooo long for finding a mistake or smth, but i have no other choice…
(Some of the “var”-s are not for use now, he just said “So when i try it out” and it worked) (I am new sorry i know nothing -_- )

your code doesn’t have velocity. velocity is used by move_and_slide. here is a very simple 2d example that moves left and right by changing velocity.

extends CharacterBody2D
func _physics_process(delta):
	velocity = Vector2.ZERO
		velocity.x = -100
		velocity.x = 100

1 Like

Hello, thanks i know that, but when i change the “speed”-var to “velocity” it is shadowing something, i tried searching it up and no solution seems to pop up…

Are you trying to say that i dont need “velocity” as var.?

the documentation has a list of variables. velocity is a property of the characterbody3d class.

Thank you very much, have a good day/night!