Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Ouch_Bird |
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