Early switch scripts working
This commit is contained in:
33
scripts/door.gd
Normal file
33
scripts/door.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
extends MeshInstance3D
|
||||
|
||||
@export var anim_player : Node
|
||||
@export var door_open_start : bool = false
|
||||
var door_open : bool
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
door_open = door_open_start
|
||||
|
||||
if door_open:
|
||||
open()
|
||||
else:
|
||||
close()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func open():
|
||||
anim_player.play("open")
|
||||
|
||||
func close():
|
||||
anim_player.play("close")
|
||||
|
||||
func state_change(switch_on):
|
||||
if door_open != switch_on:
|
||||
if switch_on:
|
||||
door_open = true
|
||||
open()
|
||||
else:
|
||||
door_open = false
|
||||
close()
|
||||
Reference in New Issue
Block a user