0

I need to use this script written in godot 3 to work in godot 4

language is 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")
100k7gm
  • 25
  • 4

1 Answers1

1

I tried it out and this way should work.

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")
GD Clone
  • 83
  • 6