extends Node3D ##左边的门 class_name trainDoor @onready var left_animation_player: AnimationPlayer = $LeftAnimationPlayer @onready var right_animation_player: AnimationPlayer = $RightAnimationPlayer ## 门的状态枚举 enum Train_Door_STATE{ idle = 0, open = 1,# 开门 close = 2,# 关门 } ##门是否移动 @onready var trainDoorState : Train_Door_STATE = Train_Door_STATE.idle : set(value): if trainDoorState != value: trainDoorState = value if trainDoorState ==Train_Door_STATE.open : left_animation_player.play("leftOpen") right_animation_player.play("rightOpen") elif trainDoorState ==Train_Door_STATE.close : left_animation_player.play("leftClose") right_animation_player.play("rightClose") var count=0 func _process(delta: float) -> void: count+=1 if count>180 and count<360: trainDoorState=Train_Door_STATE.open elif count>540 and count<720 : if self.name != "door2": trainDoorState=Train_Door_STATE.close elif count>720 and count<1000 : if self.name == "door2": trainDoorState=Train_Door_STATE.close elif count>2000 : count=0