0 votes

I getting the error in the title but I don't know why at the line that says: self.rng = RandomNumberGenerator.new()

extends Node

# This is the GameManager, the base of the game

func _ready():
    var x = Colony.new(
    Vector3(0, 0, 0), # origin
    1, # xdim
    1 # zdim

class Colony extends Spatial:

    # origin
    var origin : Vector3
    # x dimension (loops start at 0 and ends in xdim-1 in general)
    var xdim : int
    # z dimension (loops start at 0 and ends in zdim-1 in general)
    var zdim : int
    # number of points in the xz plane
    var xzdim : int

    # camera
    var camera : Camera

    func _init(origin, xdim, zdim):

        # random generator
        self.rng = RandomNumberGenerator.new()

        self.origin = origin
        self.xdim = xdim
        self.zdim = zdim
        self.xzdim = xdim*zdim
Godot version 3.2.3
in Engine by (244 points)

1 Answer

+1 vote
Best answer

You didn't define the variable rng before in class Colony, and it is also not part of the parent class Spatial. Just add...

var rng : RandomNumberGenerator

...in the class header (before the init function), and the error should be gone.

by (1,756 points)
selected by
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.