The method "is_on_floor():" isn't declared in the current class

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By axcysoriginal

I was following a 3D Kinematic car tutorial, but when i started adding the code it gave me this error: “The method “is_on_floor():” isn’t declared in the current class”
This is the entire script:

Car behavior parameters, adjust as needed

export var gravity = -20.0
export var wheel_base = 0.6 # distance between front/rear axles
export var steering_limit = 10.0 # front wheel max turning angle (deg)
export var engine_power = 6.0
export var braking = -9.0
export var friction = -2.0
export var drag = -2.0
export var max_speed_reverse = 3.0

Car state properties

var acceleration = Vector3.ZERO # current acceleration
var velocity = Vector3.ZERO # current velocity
var steer_angle = 0.0 # current wheel angle

func _physics_process(delta):
if is_on_floor():
acceleration.y = gravity
velocity += acceleration * delta
velocity = move_and_slide_with_snap(velocity, -transform.basis.y, Vector3.UP, true)

func apply_friction(delta):
if velocity.length() < 0.2 and acceleration.length() == 0:
velocity.x = 0
velocity.z = 0
var friction_force = velocity * friction * delta
var drag_force = velocity * velocity.length() * drag * delta
acceleration += drag_force + friction_force

func calculate_steering(delta):
var rear_wheel = transform.origin + transform.basis.z * wheel_base / 2.0
var front_wheel = transform.origin - transform.basis.z * wheel_base / 2.0
rear_wheel += velocity * delta
front_wheel += velocity.rotated(transform.basis.y, steer_angle) * delta
var new_heading = rear_wheel.direction_to(front_wheel)

var d =
if d > 0:
	velocity = new_heading * velocity.length()
if d < 0:
	velocity = -new_heading * min(velocity.length(), max_speed_reverse)
look_at(transform.origin + new_heading, transform.basis.y)

func _get_input():

:bust_in_silhouette: Reply From: Inces

First of all - format your code properly. We can’t see indentations in this text.

Still, I can’t see defined isonfloor function here. You check for this function in process(), but it is never created. You should pay more attention to whatever tutorial You were watching. There must be a line starting with

func isonfloor():

in it.
And You need to make one too

:bust_in_silhouette: Reply From: omggomb

Your class doesn’t declare which class it extends from. Godot then automatically assumes the class is extending Reference.

is_on_floor is part of the KinematicBody class, so you must extend your script from that class in order to use is_on_floor

Add extends KinematicBody to the top of your class.