0 votes

Im trying instance the Spaniard Enemy Scene to my Enemy Node to be a child of my Battle Scene so i can access the AnimPlayer but it keeps initilizing the variable before the scene gets instanced and crashes.
How can i make it so that it will initialize the variable after my scene has been instanced

extends Control

onready var SPAWN=$Enemy
onready var Spaniard=preload("res://Scenes/Spaniard_Enemy.tscn")

onready var Player=$Player/Player
onready var Enemy=$Enemy/Enemy
onready var PlayerAnim=$Player/Player/Sprite/Animate
onready var EnemyAnim=$Enemy/Enemy/Sprite/Animate

onready var QnA=$QnA

var num

func _ready():
    var instance
    if Ctrl.Level==1:

func _process(delta):
    if PlayerAnim.current_animation=="Hurt" or EnemyAnim.current_animation=="Hurt" or PlayerAnim.current_animation=="Attack" or EnemyAnim.current_animation=="Attack" or PlayerAnim.current_animation=="Dead" or EnemyAnim.current_animation=="Dead":
in Engine by (399 points)
edited by

I can't figure what do you mean, show us the error shown in the debugger.
(take a SS of your godot window if you can)

Also, as a suggestion, change your _process() content to the next code to be more readeable:

func _process(delta):
    var animations = [PlayerAnim,EnemyAnim]
    var anim_states = ["Hurt","Attack","Dead"]
    var choice_nodes_to_disable = [$Choice1,$Choice2,$Choice3,$Choice4]

    for anim in animations:
        if anim.current_animation in anim_states:
            for choice in choice_nodes_to_disable:
                choice.disabled = true

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.