Skip to content

Model.get_node() --> Model.get_node_or_null() - #148

Merged
ExpiredPopsicle merged 1 commit into
ExpiredPopsicle:mainfrom
PGComai:node-or-null
Aug 1, 2026
Merged

Model.get_node() --> Model.get_node_or_null()#148
ExpiredPopsicle merged 1 commit into
ExpiredPopsicle:mainfrom
PGComai:node-or-null

Conversation

@PGComai

@PGComai PGComai commented Sep 26, 2025

Copy link
Copy Markdown
Contributor

Changed this function in main and modelcontroller so it won't throw errors when the secondary model is not there.

@copygirl

copygirl commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

I believe the Godot VRM addon may always add a "secondary" node to model loaded through it.

However, it uses get_node instead of get_node_or_null:
https://github.com/V-Sekai/godot-vrm/blob/e15199f980064028bfa4fbee5e70dddb82dd55c3/addons/vrm/vrm_extension.gd#L963-L969

	if vrm_extension.has("secondaryAnimation") and (vrm_extension["secondaryAnimation"].get("colliderGroups", []).size() > 0 or vrm_extension["secondaryAnimation"].get("boneGroups", []).size() > 0):
		var secondary_node: Node = root_node.get_node("secondary")
		if secondary_node == null:
			secondary_node = Node3D.new()
			root_node.add_child(secondary_node, true)
			secondary_node.set_owner(root_node)
			secondary_node.set_name("secondary")

This piece of code results in the following error to be printed:

E 0:00:28:328 vrm_extension.gd:964 @ _import_post(): Node not found: "secondary" (relative to "copygirl_v3_0_1").
<C++ Error> Method/function failed. Returning: nullptr
<C++ Source> scene/main/node.cpp:1975 @ get_node()
vrm_extension.gd:964 @ _import_post()
main.gd:51 @ _load()
main.gd:10 @ _on_files_dropped()

If you're attempting to fix that, this PR would not help. Should be PR'd to the Godot VRM repo instead.

Otherwise, could you explain what problem this PR is supposed to fix?
I do in general agree that get_node_or_null should be used where nodes may not exist.
Maybe there's types of models that don't get this node added, so it could still be useful.

@PGComai

PGComai commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

In my setup Main.gd and ModelController.gd both throw the Node not found: "secondary" error. Maybe I'm building my models wrong, though.

@copygirl

Copy link
Copy Markdown
Collaborator

Okay, I suppose your model has neither animation nor colliders so it doesn't generate the secondary node at all.

@ExpiredPopsicle
ExpiredPopsicle merged commit e5d5ac4 into ExpiredPopsicle:main Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants