I guess that would mean it ISNT loaded in, but im just confused why this doesnt work.
outside_sad_global.gd (yes goofy ass name i know) is attached to the root node OutsideSad and the signal is emitted from dialogue in dialoguemanager, can someone help please? The error is thrown when the function is called so I know that the signal does emit well and all so no issue with dialogue manager.
"Invalid assignment of property or key 'animation' with value of type 'StringName' on a base object of type 'null instance'."
#Confused why a node that's loaded in returns null?
1 messages · Page 1 of 1 (latest)
you could put cheack in destroy function and not do anything when sandbox is null
Then it doesnt change the animation at all tho :(
then did you veriyfy that node path is correct
Yes like a thousand times 😔
from what i see dialog manager might be the issue it might be emitting the signal before node can initialize
and if not this then you could change onready into
export value and assign it manualy
But if the signal emits only after interacting with the sandbox wouldnt that mean its initialized ?
if that's the case then it should
another thing that may be happening is that you have some other code that deletes sandbox before it executes the signal
No, at least i dont have anything like that explicitly written, idk maybe godot hates sandboxes LOL
have you tried using export instend of onready?
Not yet, hold on let me try to attach the script to the sandbox instead
Okay it doesnt crash anymore but I'm getting this error now? I'm guessing this was the cause of all the problems lol, not sure why it happens tho cause it even autofilled the name when i was typing it in the script ???
your way of changing animation is werid you can just use play() function insted maybe that will solve it
I tried play() at first and it didnt work either thats why I did it like that 😔
Im wondering if it could be a bug since This node was a regular Sprite2d at first then I changed it to an animatedsprite2d, Ill try to just remake the whole node again and see if that fixes it
Still nothing ☹️
This sandbox just dgaf i swear...
have you tried redoing animation frames
Yeah it doesnt work either :(
do you have any other animated sprites like this or only this one
The player has movement animation but its not triggered through a signal
Ive changed animations through signals like this before tho Idk why it doesnt work this time
also dose it still shows the same error or just dosen't change animation
No it doesnt crash anymore in the debugger it just shows an error
there are two things that might do something one is to turn off looping on default animation and second one is to use different name than destroyed
but at this point i'm just guessing it might just be some really werid bug
and if you didnt reload project yet then you should it also might be memory corruption
I played around with the looping stuff it didnt help either, I just changed the name as well and nothing :(
I reloaded the project as well and still nothing
if you can try to remade the scene from scratch at least the relevant stuff and see if it still dose the same
Oh man
Okay Ill try that
Also is this supposed to happen??
i think so its internal resource so i don't think you can acces it like that
Stupid question but do you maybe have a space before or after the animation name?
What do you need the path for?
Also, in the ready function try printing self to see if the AnimatedSprite2D is loaded properly
Does it work if you use an @export variable instead of @onready?
It is also better for this use case too. @onready is only really fit for scenes that don't instantiate any others and are self contained.
Not a stupid question !! But no I dont I just checked
And I was just curious about the path
Im not sure if im writing it correctly, like this? It throws an error still 😢
signal destroy_sandcastle
@export var sandbox_sprite: AnimatedSprite2D
func _ready() -> void:
connect("destroy_sandcastle", self.on_sandcastle_destroyed)
func on_sandcastle_destroyed ():
print("stompled") # this prints
sandbox_sprite.play("stompled")
Mb its hard to read it from the screenshot
Ok, now that is weird.
It may be that the dialogue that triggers this is happening before the node is fully setup, does it crash instantly when running?
It is
It crashes right when the option that emits the signal is pressed
I meant as soon as the scene loads.
By the point you press that the node should be done setting itself up.
You don't add this sand castle trough code, right?
My bad No it doesnt crash as soon as the scene loads
And nope it just chills there at all times...Sorry it's hard to see it behind the 5 million collision shapes
May be worth to save the playground as its own scene so you can test in a more encapsulated way.
You can right click the node and do "Save Branch as Scene"
Pls I dont even know what to test for anymore it seems like nothing works 
Maybe i have evil godot
For now Ill just leave it like this maybe itll work for some lucky player
If you look at the remote tree when the game crashes, is the node tree how you'd expect it to be? Have you attached this script to multiple different nodes? Do you get any errors in the debugger panel about how a node path was invalid?
yep check if it's attached to the node where you are expecting it to be attached and no other nodes. just make sure that is the only node with that script
The playground node becomes seperate like this is this supposed to happen ??
And the script is only attached to Playground (area2d
how are you adding the playground node to that scene..?
that looks like preload(".../.gd").new()
It was just a regular node inside of the scene at first but I clicked save branch as scene
What does that mean ?
did you add it through code or did you add it to the main scene through the editor?
I added it to the main scene through the editor
if you are adding it through code a common mistake is to load the script and instantiate that instead of loading the scene, which leaves all child nodes from that scene behind
okay
then for some reason all child nodes are being deleted or lost for other reasons
show your main scene that includes playground
i don't see the OutsideSad node in this remote tree?
Wait leme try again
ah did you launch just the playground scene alone?
Should I show the tree for the main scene or justthe playground scene ?
Yeah
Huhh How does that happen
are you perhaps loading the playground scene another way
Not on purpose at least ☹️ I dont know how else that would happen
Check your project settings global> autoload tab
Ohh..I have the script set as a global, could that be causing the problem ? I needed it to be a global so that I could emit its signal from dialoguemanager
Making it global adds another node to the scene tree
See that global node in the remote tree? That’s there because it is an autoload
That makes sense... Thank you for finding the issue
Do you know how else I oculd emit the signal :( Through a different global script ?
Depends how you want to emit and connect the signal, you usually don’t really need them to be global if it’s just connecting up the tree
Otherwise just add that signal to Global instead
Okay Ill do that, Im using dialoguemanager so the signal has to belong to a global
Thank you so much for the help!!!
Thank you to everyone who helped you guys are lifesavers 🙏
Sorry how can I connect a signal to a function in a different file
? Do I have to preload that file or would that just cause the same error since im connecting it from global ?
Every global node can be accessed by its name, so
Global.some_signal.connect(do_something)
Global.some_signal.emit()
I meant like since I can only emit global signals from dialogue manager I could just put the destroy_sandcastle signal in Global and then in global.gd connect that signal to on_sandcastle_destroyed in sandbox.gd , is that possible?
easier to connect in sandbox.gd exactly because you can acces the global everywhere
loading the script like that won't work exactly because you need to get that specific instance of sandbox, not just any sandbox
like with the playground issue you suddenly had two playgrounds you can't just load a second sandbox and expect that to connect to the first
OH MY GODS IT WRKS
WORKS
Thank you so much dude
I didnt know you could connect signals like that
you might have been using godot3 tutorials, godot 4 added this way