migueldeicaza / SwiftGodot

New Godot bindings for Swift
https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot-tutorials/
MIT License
1.06k stars 65 forks source link

The example in "@onready annotation" in the docs produces errors #443

Closed roydbt closed 4 months ago

roydbt commented 5 months ago

The example:

class Demo: Node {
    var myLabel: Node3D

    override func _ready () {
        myLabel = getNode (path: "myLabel") as? Node3D
    }
}

produces the following errors:

  1. The class "Demo" doesn't have initializers
  2. Something about how "getNode (path: "myLabel") as? Node3D" produces "Node3D?" and not "Node3D" for myLabel
migueldeicaza commented 4 months ago

Thanks, the docs have been updated, for now do:

  1. Add @Godot attribute to the class
  2. Change the Node3D to "Node3D?"