SwiftGodot: result of `PackedScene.instantiate()` cannot be casted

  • I have a SwiftGodot subclass of Node3D that is available to godot via a .gdextension, lets call it MyLevel
  • I create a scene of that type (MyLevel) and save it as “TestLevel.tscn”
  • I can load the packed scene at “TestLevel.tscn” just fine
  • I can instantiate it, but the resultant type is of Node
  • when I print Node I see that it’s of type MyLevel in the string description
  • when I cast to MyLevel it fails
  • using MyLevel(nativeHandler: handle) seems to work, but it’s unsafe

potentially related, or at least similar to #166 I’m not sure if it’s related, but I get similar issue when using generics and Variant/ObjectCollection, or GDictionary

a slack thread here: https://swiftongodot.slack.com/archives/C05BYJ95S5D/p1703355812284309

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Comments: 34 (34 by maintainers)

Most upvoted comments

Could you update to main, and report what the console output is when this fails?

I added two print() statements, that should help me out.