0 votes

Hi, my code looks something like this:

func _ready():
    var test = SecondClass.new(4)

class FirstClass:
    var a
    func _init(a):

class SecondClass:
    extends FirstClass
    func _init(a).(a):

    func method_example():

However I have not fo und a way to access a from SecondClass, is this even possible?

in Engine by (66 points)

1 Answer

+2 votes
Best answer


the problem here is that you pass a parameter named a and have a instance field named a. Prefix your variable with self to point to the instance variable (or change the parameter name). Then it will work.

class FirstClass:
var a
func _init(a):
by (310 points)
selected by

Yeah, that made it work, thanks!

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.