0 votes

I'm a total noob in GDscript and i lately started following a course on how to make a 2D platformer from udemy
i followed everything but in

"func adjust_flip_direction(input ; Vector2 );"

it keeps asking for , or )
please help

extends KinematicBody2D

export(float) var move_speed = 200
export(float) var jump_impulse = 600
enum STATE { IDLE, RUN, JUMP }

onready var animation_sprite = $AnimatedSprite
onready var animation_tree = $AnimationTree

var velocity : Vector2

var current_state = STATE.IDLE setget set_current_state
var jumps = 0

# warning-ignore:unused_argument
func _physics_process(delta):
    var input = get_player_input()
    adjust_flip_direction(input)

    velocity = Vector2(
        input.x * move_speed,
        min(velocity.y + Global.gravity, Global.terminal_velocity)
    )

    velocity = move_and_slide(velocity, Vector2.UP)

    set_anim_parameters()

    pick_next_state()

func adjust_flip_direction(input ; Vector2 );
    if(sign(input.x) == 1):
        animated_sprite.flip_h = false
    elif(sign(input.x) == -1):
        animated_sprite.flip_h = true
func set_anim_parameters():
    animation_tree.set(("parameters/x_move/blend_position"),sign(velocity.x))

func pick_next_state():
    if(is_on_floor()):
        jumps = 0

        if(Input.is_action_just_pressed("Up")):
            self.current_state = STATE.JUMP
        elif(abs(velocity.x) > 0):
            self.current_state = STATE.RUN
        else:
            self.current_state = STATE.IDLE
    else:
        pass

func get_player_input():
# warning-ignore:unassigned_variable
    var input : Vector2

    input.x = Input.get_action_strength("Right") - Input.get_action_strength("Left")
    input.y = Input.get_action_strength("Down") - Input.get_action_strength("Up")

    return input

func jump():
    velocity.y = -jump_impulse
    jumps += 1

# SETTERS
func set_current_state(new_state):
    match(new_state):
        STATE.JUMP:
            jump()


    current_state = new_state
Godot version v3.3.4.stable.official
in Engine by (19 points)

1 Answer

0 votes
Best answer

You've written ; instead of : (in two places):

func adjust_flip_direction(input : Vector2 ):
by (20,675 points)
selected by

I just tried and it says "the identifier "animated_sprite" isn't declared in the current scope."

Well, that's because you don't have a variable named that. You've declared one called animation_sprite at the top of your script...

oh... now it works, thanks ^_^

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.