-
-
Notifications
You must be signed in to change notification settings - Fork 21k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instanced Sprite with ViewportTexture produces infinite error spam #55818
Comments
I'm guessing that you have added a Viewport as a child of the root Sprite2D? Otherwise I don't know how you were able to set a Viewport Texture. Before I start getting
So If I look at the instanced node, the Viewport Path is still just Viewport. I'm guessing that Godot is trying to get a Viewport at /Level/Viewport instead of /Level/Sprite/Viewport. If there's a bug in this issue, my guess is that it's here, expecially after reading the following from the documentation about the viewport_path variable : So technically speaking, this isn't actually a bug as it's the documentation's expected behavior, although I find it weird... I fixed this with a few lines of code in ready to set the new viewport_path of the instanced node:
Note that get_path() returns an EditorNode with tool (as it runs in the editor), but should work fine in game. edit: I kept |
I recommend removing the bug tag as this is actually the expected behavior, detailed in my previous comment |
I don't really get how local to scene works. I assume it uses owner to determine the root node and it behaves differently with instanced root. I'd have to take a closer look, but for now documenting that you can't use ViewportTexture in a root node (unless it's not instanced) should suffice. |
Please fix this. I ran into this bug and its very annoying. |
I think error description should at least be more clear on what is causing the failure, this way it can be settled up propperly |
local to scene will make a unique duplicate of the resource on _init of the node, this allows in example to have unique instances of materials so you can change their properties on every node without sharing the same material on all of them |
No my confusion was about something else (I know about the duplicating behavior). |
godot/doc/classes/Resource.xml Lines 70 to 72 in 736e3b7
I'm not sure if the above instance refers to the instance of the resource or the instance of the sub-scene. But in any case, it makes sense to limit the If the above instance refers to the instance of the sub-scene, I think #64388 (solve the problem when godot/scene/resources/packed_scene.cpp Lines 277 to 306 in dbd1524
The code above seems to show that resources with If not then I may need to modify #64487 and #64526. How about renaming
|
Not sure where this stands, but it seems to me like the problem is that the node path for viewports can't be relative. They always refer to the path via the root node as mentioned;
Since instancing always changes the root, it's always going to cause the problem. Making the resource local to scene and correcting the path does fix the error, but then it would mean all instanced viewport textures need to be set individually. The tool script does work, but it seems like a baindaid to make the path relative. If it were relative by default, (like other node path properties, AnimationPlayer's "root" for example) you wouldn't even have to make things local to scene because the texture would still be able to find the viewport when it's instanced. Maybe there's some reason that it has to be relative to the scene root? |
Godot version
3.4 / 4.0 092a286
System information
W10
Issue description
When you have a scene with Sprite root and assign a ViewportTexture to it, this happens when you instance it in another scene:
Steps to reproduce
Minimal reproduction project
ReproductionProject.zip
Open Spam.tscn and move cursor over 2D viewport.
The text was updated successfully, but these errors were encountered: