#Confused why a node that's loaded in returns null?

1 messages · Page 1 of 1 (latest)

pearl garnet
#

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'."

halcyon finch
#

you could put cheack in destroy function and not do anything when sandbox is null

pearl garnet
halcyon finch
#

then did you veriyfy that node path is correct

pearl garnet
halcyon finch
#

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

pearl garnet
halcyon finch
#

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

pearl garnet
halcyon finch
#

have you tried using export instend of onready?

pearl garnet
#

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 ???

halcyon finch
#

your way of changing animation is werid you can just use play() function insted maybe that will solve it

pearl garnet
#

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...

halcyon finch
#

have you tried redoing animation frames

pearl garnet
halcyon finch
#

do you have any other animated sprites like this or only this one

pearl garnet
#

Ive changed animations through signals like this before tho Idk why it doesnt work this time

halcyon finch
#

also dose it still shows the same error or just dosen't change animation

pearl garnet
halcyon finch
#

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

pearl garnet
#

I reloaded the project as well and still nothing

halcyon finch
#

if you can try to remade the scene from scratch at least the relevant stuff and see if it still dose the same

pearl garnet
#

Okay Ill try that

#

Also is this supposed to happen??

halcyon finch
#

i think so its internal resource so i don't think you can acces it like that

pearl garnet
#

Oh okey

#

Man why doesnt this work gdlament

fringe blade
#

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

rose nexus
#

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.

pearl garnet
#

And I was just curious about the path

pearl garnet
#
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

rose nexus
pearl garnet
rose nexus
#

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?

pearl garnet
rose nexus
#

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"

pearl garnet
#

Maybe i have evil godot

#

For now Ill just leave it like this maybe itll work for some lucky player

worn dove
boreal cedar
#

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

pearl garnet
#

And the script is only attached to Playground (area2d

boreal cedar
#

that looks like preload(".../.gd").new()

pearl garnet
#

It was just a regular node inside of the scene at first but I clicked save branch as scene

pearl garnet
boreal cedar
#

did you add it through code or did you add it to the main scene through the editor?

pearl garnet
boreal cedar
#

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

boreal cedar
pearl garnet
boreal cedar
#

ah did you launch just the playground scene alone?

pearl garnet
#

Should I show the tree for the main scene or justthe playground scene ?

boreal cedar
#

okay

#

still seems like you have two playground nodes in that case

pearl garnet
pearl garnet
boreal cedar
#

are you perhaps loading the playground scene another way

pearl garnet
boreal cedar
pearl garnet
boreal cedar
#

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

pearl garnet
boreal cedar
#

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

pearl garnet
#

Thank you so much for the help!!!

#

Thank you to everyone who helped you guys are lifesavers 🙏

pearl garnet
boreal cedar
pearl garnet
boreal cedar
#

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

pearl garnet
#

OH MY GODS IT WRKS

#

WORKS

#

Thank you so much dude

#

I didnt know you could connect signals like that

boreal cedar
#

you might have been using godot3 tutorials, godot 4 added this way