C

DirAccess cannot be constructed as it is abstract

CommonBruno

I've followed the instructions for the creation of a player entity,homever when i tried to run the program the following error showed up
"Parser Error: Native class "DirAccess" cannot be constructed as it is abstract."

Related to those 4 lines of code:
var directory := DirAccess.new()
var can_continue := directory.open(directory_path) == OK
var file_name := directory.get_next()
files.append(directory_path.plus_file(file_name)

I dont know how the problem could have been caused,and i understand the problem stands in the call of DirAccess from Directory which causes future errors,but i dont know what the method itself does or how to replace it so id like some help on the matter if possible

  • C
    CommonBruno replied

    Thought id add a screenshot too
    scr.png

  • C
    CommonBruno replied
    Another user had a similar problem,but their solution doesnt work for me,this problem presents itself in all versions of godot 4 and previous versions wont even start
  • Nathan Lovato replied

    It appears that you imported the project into Godot 4, which did a conversion of the project files, which causes issues as this conversion is just a tool to save developers time when porting Godot 3 games to Godot 4 - but it still leaves a lot of work to be done manually.

    This course is for Godot 3, so you can't use Godot 4 to follow it. Because you already converted the files, you'll need to re-download the course files and import this fresh copy in Godot 3.

    I hope this helps!