我需要帮助将此代码从 Godot 3“翻译”到 Godot 4

问题描述 投票:0回答:1

我需要使用 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")
godot translate godot4 godot3
1个回答
0
投票

我尝试了一下,这个方法应该可行。

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")
© www.soinside.com 2019 - 2024. All rights reserved.