The method "apply_friction" isn't declared in the current class.

Attention Topic was automatically imported from the old Question2Answer platform.

I am following a tutorial and am brand new to the engine, coding, and game designing in general. Regardless, I do not understand why this error is popping up for me as no one else has commented a problem like mine. Something has to have changed as my code looks exactly as the tutorials.

``````extends KinematicBody

export var gravity = -20.0
export var wheel_base = 0.6
export var steering_limit = 10.0
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

var acceleration = Vector3.ZERO
var velocity = Vector3.ZERO
var steer_angle = 0.0

func _physics_process(delta):
if is_on_floor():
get_input()
apply_friction(delta)                 #This is the problem child.
calculate_steering(delta)
acceleration.y = gravity
velocity += acceleration * delta
velocity = move_and_slide_with_snap(velocity, -transform.basis.y, Vector3.UP, true)

func apply_fcrition(delta):
if velocity.length() < 0.2 and acceleration.length() == 0:
velocity.x = 0
velocity.z = 0
var friction_force = velocity * friction * delta
var drag_froce = velocity * velocity.length() * delta
acceleration += drag_force + friction_force                         #This is giving me problems as well.
``````

I have no idea why its being changed. But it looks like this. “apply_friction(delta)”

I edited your post to fix the formatting. Please use the “code sample” button when posting code.

kidscancode | 2021-06-25 17:47

It’s saying `apply_friction()` isn’t defined, because you defined this:

``````func apply_fcrition(delta):
``````

Wow, can’t believe I missed that. Took me a minute to see where that was.

Can anyone help with the second problem?

“The identifier “drag_force” isn’t declared in the current scope.”

Ouch_Bird | 2021-06-25 18:05

Same thing. You wrote `drag_froce` on the line before.

kidscancode | 2021-06-25 18:22

This is quite embarrassing.

"Can’t get index “basic” on base “transform”.

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

appreciate all the help regardless of how stupid the mistake’s are. lol!

Ouch_Bird | 2021-06-25 18:36

It’s `basis`, not `basic`.

Since you are a beginner, this really isn’t the best tutorial for you to start with. This is intended for people who already have some understanding of the engine and coding.

I highly recommend you start with the “Your First Game” tutorial that’s in the official docs. It explains a lot of the basics that you need to know.

Step by step — Godot Engine (stable) documentation in English

kidscancode | 2021-06-25 18:42