1

When I use (Morton.morton_statetest) in another script, It gives me 0, and even if I put a print in Morton script and If I put an print in the other script, it gives me two values different, wit out any error in the terminal.

extends AnimatedSprite2D

var morton_statetest := 0
var rng := RandomNumberGenerator.new()
var running := false
var morton_hall_trigered := false
@onready var morton_hall_spr := self
var animatronic := "morton"
var morton_position := 99

func _process(_delta: float) -> void: #SUPER SPAGUETTI
    if morton_statetest == 0:
        morton_position = 99
    elif morton_statetest == 1:
        morton_position = 6
    elif morton_statetest == 2:
        morton_position = 7
    elif morton_statetest == 3:
        morton_position = 4
    elif morton_statetest == 4:
        morton_position = 5
    elif morton_statetest == 5:
        morton_position = 0


func _on_morton_timer_movement_timeout() -> void:
    if morton_statetest <= 4 && Global.alive == true:
        var numero_aleatorio_morton = rng.randi_range(1, 21)
        if numero_aleatorio_morton < Global.dificulty_morton:
            get_node("/root/Night 1/Camera2D/Ui/Estatica_spr").modulate.a = 1
            morton_statetest += 1
            print("morton state: ", morton_statetest)
            print("morton position: ", morton_position)
            await get_tree().create_timer(0.5).timeout
            get_node("/root/Night 1/Camera2D/Ui/Estatica_spr").modulate.a = 0.2

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.