0 votes

I was making a movement script following Heartbeasts's tutorial but I got the error "The method "getinputaxis" isn't declared in the current class" and "The argument 'amount' is never used in the function 'applymovement'. 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)
asked May 24 in Engine by Hamzailer (15 points)

1 Answer

+1 vote
Best answer

Your function is named get_axis() not get_input_axis()

answered May 24 by kidscancode (16,966 points)
selected May 25 by Hamzailer

Tysm but now I'm getting the error: The identifier "motion" isn't declared in the current scope.

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.