0 votes

I understand what the error means, but I can 't see where is the problem.

So here is the main scene script:

extends Node


func _init():
    var hexPlanet : HexPlanet = HexPlanet.new() # here is the error
    add_child(hexPlanet)

    var balls = preload("res://Assets/Auxiliar/Balls.tscn").instance()
    add_child(balls)

    var camera = preload("res://Assets/Cameras/CameraGimbal/CameraGimbal.tscn").instance()
    add_child(camera)

The HexPlanet script:

class_name HexPlanet
extends Spatial


var R : int = 10
var rng : RandomNumberGenerator = RandomNumberGenerator.new()
var tilesVpositions : PoolVector2Array


func _ready():

    rng.randomize()

    tilesVpositions = GLOBALS.hex_circle(Vector2.ZERO, R)

    var tile : Tile
    for i in range(tilesVpositions.size()):
        tile = Tile.new(tilesVpositions[i])
        #tile.change_center(MATERIALS.WHITE)
        add_child(tile, true)

GLOBALS is an autoload and Tile is another class I created, but didn't give me errors in the past (all pieces of code work separately). The game is executed and the result is correct, but I get the error The class 'HexPlanet' couldn't be fully loaded (script error or cyclic dependency) I need to solve this to go further in my project.

Thanks!

Godot version 3.2.3
in Engine by (244 points)

1 Answer

0 votes

I have never seen this manner of introducing variable. Do You have to assign type as your HexPlanetclass right before You assign value as new script of it ?

Try without it, like :

var hexPlanet = HexPlanet.new()
by (7,743 points)

So this morning I opened Godot, I executed the game and the problem vanished without changing nothing XD. Can you explain me why?

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.