我需要使用 godot 3 编写的这个脚本在 godot 4 中工作
语言是gdscript
extends Path2D
enum ANIMATION_TYPE {
LOOP,
BOUNCE,
}
export(ANIMATION_TYPE) var animation_type
onready var animationPlayer: = $AnimationPlayer
func _ready():
match animation_type:
ANIMATION_TYPE.LOOP: animationPlayer.play("MoveAlongPathLoop")
ANIMATION_TYPE.BOUNCE: animationPlayer.play("MoveAlongPathBounce")
我尝试了一下,这个方法应该可行。
extends Path2D
enum ANIMATION_TYPE {
LOOP,
BOUNCE,
}
@export var animation_type : ANIMATION_TYPE
@onready var animationPlayer: = $AnimationPlayer
func _ready():
match animation_type:
ANIMATION_TYPE.LOOP: animationPlayer.play("MoveAlongPathLoop")
ANIMATION_TYPE.BOUNCE: animationPlayer.play("MoveAlongPathBounce")