Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | hoangHIeu |
so i have a little problem while learning godot course by gamedev.team, so yan can use func update(motion), but i cant, it is said : parent signature is " void update():"
so how can i fix this to continue the course
PlayerScript :
extends KinematicBody2D
const SPEED = 750
const GRAVITY = 2000
const JUMP_SPEED = -1000
const UP = Vector2(0,-1)
var motion = Vector2()
func _physics_process(delta):
fall(delta)
Run()
jump()
move_and_slide(motion,UP)
func _process(delta):
update_animation(motion)
func update_animation(motion):
$AnimatedSprite.update(motion)
func fall(delta):
if is_on_floor():
motion.y = 0
else:
motion.y += GRAVITY * delta
func Run():
if Input.is_action_pressed(“ui_right”) and not Input.is_action_pressed(“ui_left”):
motion.x = SPEED
elif Input.is_action_pressed("ui_left") and not Input.is_action_pressed("ui_right") :
motion.x = -SPEED
else:
motion.x = 0
$AnimatedSprite.play("idle")
$AnimatedSprite.flip_h = false
func jump():
if is_on_floor() and Input.is_action_pressed(“ui_up”):
motion.y = JUMP_SPEED
and the func update script :
extends AnimatedSprite
func update(motion):
if motion.x > 0:
play(“run”)
flip_h = false
elif motion.x < 0 :
play(“run”)
flip_h = true
else:
play(“idle”)
help me