+1 vote

I'm building a grid-based game. I have a tile script which is extended to an actor script. This actor script is then extended to a player and an npc script.

The tile script has a variable called "block" as seen here:

@export var block : bool

I am trying to set it so that all "actor" based classes have block set to true by default:

block = true

I get the following error for both my player and npc classes:

Parse Error: Could not resolve super class inheritance from "res://actors/actor.gd".

What have I done wrong?

Godot version 4.0
in Engine by (93 points)

I could not reproduce the situation. Don't you have any other clue?

I'm on the Godot 4.0 Beta, so maybe that's why. But there's not really much other information.

tile.gd :

extends Node2D

@export var block : bool = false

actor.gd :

extends "res://tile.gd"

block = true

player.gd :

extends "res://actors/actor.gd"

Here's the Error I get:

Error at (0, 0): Could not resolve super class inheritance from "res://actors/actor.gd".

Well, that's the error I get in the player.gd script. In the actor script itself I get an error stating: Unexpected "Identifier" in class body. and it highlights my block = true line

I don't think the sentence block = true in actor.gd is syntactically correct, it cannot be in preamble. We can write it in _ready() instead.
It is not important, but I am wondering why you don't use class_name for the tile and the actor.

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.