![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | ZSakaro |
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