![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Hamzailer |
I was making a movement script following Heartbeasts’s tutorial but I got the error “The method “get_input_axis” isn’t declared in the current class” and “The argument ‘amount’ is never used in the function ‘apply_movement’. If this is intended, prefix it with an underscore: ‘_amount’”, Any ways to fix this?
The Script:
extends KinematicBody2D
var MaxSpeed : = 300
var PlayerAcceleration : = 1200
var Motion : = Vector2.ZERO
func _physics_process(delta):
var axis = get_input_axis()
if axis == Vector2.ZERO:
apply_friction(PlayerAcceleration * delta)
else:
apply_movement(axis * PlayerAcceleration * delta)
motion = move_and_slide(Motion)
func get_axis():
var axis = Vector2.ZERO
axis.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
axis.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
func apply_friction(amount):
if motion.length > amount():
motion -= motion.normalized() * amount
else:
motion = Vector2.ZERO
func apply_movement(amount):
motion += acceleration
motion = motion.clamped(MaxSpeed)