Ok, so I got this class ```ts
class_name TowerDefenseEnemy extends CharacterBody2D
@export var currentHealth:SeperatedNumber
@export var isDead:bool = false
var maxHealth:int = 5
#var towerDamage:SeperatedNumber = SeperatedNumber.new().init(1)
var movePerTick:float = 0.25
#var test:SeperatedNumber = SeperatedNumber.new()
#var test:Resource = Resource.new()
func init(pos:Vector2,parent):
position = pos
parent.add_child(self)
owner = GameManager.saveNode
currentHealth = SeperatedNumber.new().init(maxHealth)
var collision = CollisionShape2D.new()
collision.shape = RectangleShape2D.new()
collision.shape.size = Vector2(8, 8)
add_child(collision)
collision.owner = GameManager.saveNode
var sprite = Sprite2D.new()
sprite.texture = load("res://textures/items/stackable/stone.png")
sprite.scale = Vector2(0.5, 0.5)
collision.add_child(sprite)
sprite.owner = GameManager.saveNode
return self
func died():
isDead = true
queue_free()
func tick():
var target = Vector2(0,0)
var angle = position.angle_to_point(target)
var toMove = Vector2(movePerTick, 0).rotated(angle)
position += toMove
If I uncomment any of the commented out lines, I get a weird error when saving E 0:00:05:0969 game_manager.gd:677 @ saveGame(): Resource was not pre cached for the resource section, bug?
<C++-Fehler> Method/function failed. Returning: "null"
<C++-Quelle> scene/resources/resource_format_text.cpp:1569 @ _write_resource()
<Stacktrace> game_manager.gd:677 @ saveGame()
game_manager.gd:576 @ newGame()
This seems to happen with any variable that has a value that is a resource or a class that extends resource
It also happens when the variable is not typed
```ts
@export var enemies:Array = []
func spawnEnemy():
var enemyPos = GeneralFunctions.getPointOnRectBorder(enemySpawnArea)
var enemy = TowerDefenseEnemy.new().init(enemyPos,self)
enemies.append(enemy)```This is in another class, the error doesn't occur when I remove the @export from the array or I don't put instances in there
For reference, I save and load my game, bu just saving my saveNode to a resource and then save it as a file and instantiate it later.
A weird thing I noticed is, when creating a new save, and then looking into the remote tree, these resource variables will have propper values, but when saving and loading and then looking at instances that were created before the save and load, these NOT exported variables are null. I have no idea how that can even happen, but apparently it does.
I talked to a friend of mine in the godot cafe server, he knows a lot more about godot than me, he said its most likely to be an engine bug, si Im bringing it up here.
If you have any idea, please let me know and thanks a lot in advance