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

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: 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)
		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
		motion = Vector2.ZERO

func apply_movement(amount):
	motion += acceleration
	motion = motion.clamped(MaxSpeed)
:bust_in_silhouette: Reply From: kidscancode

Your function is named get_axis() not get_input_axis()

Tysm but now I’m getting the error: The identifier “motion” isn’t declared in the current scope.

Hamzailer | 2020-05-24 20:13

You capitalized “Motion” at the top. You seem to have made a lot of typos. Check your code carefully with the code in the tutorial.

kidscancode | 2020-05-24 20:15